#include <stdio.h>
int main()
{
char c;
int letters=0,space=0,num=0,other=0;
printf("输入一行字符n");
while((c=getchar())!='n')
if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
letters++;
else if(c==' ')
space++;
else if(c>='0' && c<='9')
num++;
else
other++;
//辅导Q 5238_57886
printf("字母数:%dn空格数:%dn数字数:%dn其他字符数:%dn",letters,space,num,other);
return 0;
}
最后
以上就是怕孤独路人最近收集整理的关于C 语言 字符串统计 各类字符出现的次数的全部内容,更多相关C内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复