4.利用if else语句编写程序读取输入,直到#。用一个感叹号代替每个句号,将原有的每个感叹号用两个感叹号代替,最后报告进行了多少次替代。
#include <stdio.h>
int main(void)
{
char ch;
int count1= 0,count2= 0;
printf("Please type your words\n");
while((ch=getchar())!= '#')
{
if(ch== '.')
{ putchar('!'); count1++;}
else if(ch== '!')
{ putchar('!');putchar('!'); count2++;}
else
putchar(ch);
}
printf("In total %d times replacement\n",count1+count2);
}
5.用switch重做练习3。