本题要求编写程序,输入一行字符,统计其中数字字符、空格和其他字符的个数。建议使用switch语句编写。
输入格式:
输入在一行中给出若干字符,最后一个回车表示输入结束,不算在内。
输出格式:
在一行内按照
blank = 空格个数, digit = 数字字符个数, other = 其他字符个数
的格式输出。请注意,等号的左右各有一个空格,逗号后有一个空格。
输入样例:
在这里给出一组输入。例如:
Reold 12 or 45T
结尾无空行
输出样例:
在这里给出相应的输出。例如:
blank = 3, digit = 4, other = 8
结尾无空行
#includeint main() { int blank, digit, other; char ch; blank = digit = other = 0; ch = getchar(); while(ch!='n') { switch(ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': digit++; break; case ' ': blank++; break; default: other++; break; } ch = getchar(); } printf("blank = %d, digit = %d, other = %d", blank, digit, other); return 0; }



