/*1.编写一个程序。该程序读取输入直到遇到#字符,然后报告读取的空格数目、读取的换行符数目以及读取的所有其他字符数目。*/
#include<stdio.h>
#include<stdlib.h>
#define STOP '#'
int main()
{
char a;
int space = 0, enter = 0, others = 0;
printf("Please input:");
while ((a = getchar()) != STOP)
{
if (a == ' ')
space++;
else if (a == '\n')
enter++;
else others++;
}
printf("%dspaces %denters %dothers\n", space, enter, others);
system("pause");
return 0;
}
C Primer Plus7-1
最新推荐文章于 2024-09-28 21:40:24 发布