#include <conio.h>
int main(){
printf("请输入一行字符:");
char num;
int num_yingwen=0,num_space=0,num_shuzi=0,num_other=0;
while((num=getchar())!='\n'){
if(num >= 'a'&&num <= 'z' || num >= 'A'&&num <= 'Z')
num_yingwen++;
else if(num==' ')
num_space++;
else if(num>='0'&&num<='9')
num_shuzi++;
else
num_other++;
}
printf("英文个数为%d,空格字数为%d,数字字数为%d,其他字符个数为%d",num_yingwen,num_space,num_shuzi,num_other);
getchar();
return 0;
} 总结
以上是内存溢出为你收集整理的输入一行字符,分别统计其中英文字母、空格、数字和其他字符的个数全部内容,希望文章能够帮你解决输入一行字符,分别统计其中英文字母、空格、数字和其他字符的个数所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)