#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
char c;
int space_num= 0;
int nextline_num= 0;
int other_num= 0;
printf("Please type some words.\n");
while((c= getchar())!= '#')
{
if(c== '\n')
nextline_num++;
else if (c== ' ')
space_num++;
else
other_num++;
}
printf("The number of space is %d\n",space_num);
printf("The number of nextline is %d\n",nextline_num);
printf("The other char number is %d\n",other_num);
return 0;
}
1.编写一个程序。该程序读取输入直到遇到#字符,然后报告读取的空格数目、读取的换行符数目以及读取的所有其他字符数目。
c primer plus 第七章 1
最新推荐文章于 2024-08-05 18:37:39 发布