本文共 622 字,大约阅读时间需要 2 分钟。
统计字符个数
#include用for循环的处理办法int main(){ char c; int count=0; while((c=getchar())!='\n') { count++; } printf("\n"); printf("There are %d characters.\n", count); return 0;}
#include统计数字字符个数int main(){ char c; int i; for(i=0; (c=getchar())!='\n';i++) putchar(c+4); printf("\n"); printf("There are %d characters.\n", i); return 0;}
#includeint main(){ char c; int n=0; printf("Input a sentence: "); while((c=getchar())!='\n') { if(c>='0'&&c<='9') n++; } printf("There are %d number characters.\n", n); return 0;}
转载地址:http://wihcx.baihongyu.com/