#include <stdio.h>
int main()
{
char s[20];
char num=0;
int num_count=0;
int space_count=0;
int other_count=0;
while((num=getchar())!='\n')
{
if(num>='0'&&num<='9')
{
num_count++;
}
else if(num==' ')
{
space_count++;
}
else
{
other_count++;
}
}
printf("num_count=%d\n",num_count);
printf("space_count=%d\n",space_count);
printf("other_count=%d\n",other_count);
return 0;
}
【C语言】编写一个程序统计输入字符串中: 各个数字、空白字符、以及其他所有字符出现的次数。
最新推荐文章于 2022-04-17 18:16:41 发布