#include<stdio.h>
#include<string.h>
int main()
{
char a[40];
int i, j = 0, m = 0, n = 0, b = 0,t=0;
scanf("%s", a);
t=strlen(a);
for (i = 0; i <t ; i++)
{
if (a[i] >= '0'&&a[i] <= '9')
j += 1;
else if (a[i] >= 65 && a[i] <= 90 || a[i] >= 97 && a[i] <= 122)
m += 1;
else if (a[i] ==32) n += 1;
else b += 1;
}
printf("zimu=%d\n", m);
printf("shuzi=%d\n", j);
printf("kongge=%d\n", n);
printf("qita=%d\n", b);
}
问题:统计字符串中字母、数字、空格和其他字符的个数。
运行后各个统计的结果都不正确
相关分类