c primer plus 第七章 1

来源:互联网 发布:淘宝里没有淘龄怎么办 编辑:程序博客网 时间:2024/04/30 02:26
#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++;elseother_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.编写一个程序。该程序读取输入直到遇到#字符,然后报告读取的空格数目、读取的换行符数目以及读取的所有其他字符数目。
原创粉丝点击