欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C++實(shí)現(xiàn)將輸入復(fù)制到輸出的方法

 更新時(shí)間:2015年07月30日 16:31:11   作者:defias  
這篇文章主要介紹了C++實(shí)現(xiàn)將輸入復(fù)制到輸出的方法,實(shí)例分析了C++字符串轉(zhuǎn)換及輸入輸出操作的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了C++實(shí)現(xiàn)將輸入復(fù)制到輸出的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

將輸入復(fù)制到輸出的程序, 并將其中的制表符替換為\t, 把回退符替換為\b, 把反斜杠替按為\\

#include <stdio.h>
main()
{
 int ch;
 ch=getchar();
 while(ch != EOF){
  if(ch == '\t'){
   putchar('\\');
   putchar('t');
  }
  else if(ch == '\b'){
   putchar('\\');
   putchar('b');
  }
  else if(ch == '\\'){
   putchar('\\');
   putchar('\\');
  }
  else
   putchar(ch);
 ch=getchar();
 }
}

將輸入復(fù)制到輸出的程序, 并將其中連續(xù)的多個(gè)空格用一個(gè)空格代替:

#include <stdio.h>
main()
{
 int ch;
 int n=0;
 ch=getchar();
 while(ch != EOF){
  if(ch == ' '){
   n++;
   if(n<=1)
    putchar(ch);
  }
  else if(ch == '\n'){
   putchar(ch);
   n=0;
  }
  else{
   putchar(ch);
   n=0;
  }
  ch=getchar();
 }
}

希望本文所述對(duì)大家的C++程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論