问题://编写程序读入,读到#停止,报告ei出现的次数
#include<stdio.h>
int main()
{
char ch;
int e=0,num=0;
printf("please imput some char:\n");
while((ch=getchar())!='#')
{
if(ch=='e')
e=1;
else
if(e==1&&ch=='i')
{
e=0;
num++;
}
}
printf("The sum is:%d\n",num);
return 0;
}
其中if else的运用是变化莫测的。
自己的日记博客加油。