编写一段程序,要求先输入一行字符,然后分别统计出其中英文字母、空格、数字和其他字符的个数,并输出其结果。

admin2017-12-15  22

问题 编写一段程序,要求先输入一行字符,然后分别统计出其中英文字母、空格、数字和其他字符的个数,并输出其结果。

选项

答案#include Main() { char c; int letter=0,spA,Ce=0,digit=0,other=0; prinff("请输入一行字符:\n"); while((c=getcharO)!=‘\n) { if>=‘a’&&c<=‘z’||c>=‘A’&&c<=‘Z’) letter++; else if(e==‘’) spA,Ce++; else if(c>=‘0’&&c<=‘9’) digit++; else other++; } printf("字母数=%d,空格数=%d,数字数=%d,其他字符=%d\n",letter,spA,Ce,digit,other); }

解析
转载请注明原文地址:https://kaotiyun.com/show/AD7v777K
0

最新回复(0)