#include<stdio.h>
int main()
{
char ch;
int letter=0, dight=0, blank=0, other=0;
while ((ch = getchar()) !='\n')
{
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
{
letter++;
}
else if (ch >= '1' && ch <= '9')
{
dight++;
}
else if (ch == ' ')
{
blank++;
}
else
{
other++;
}
}
printf("%d ", letter);
printf("%d ", dight);
printf("%d ", blank);
printf("%d", other);
return 0;
}
ch是字符吧,不是字符串
14行数字条件应该是ch大于等于'0',小于等于'9'。少了数字0吧。其他没问题
没通过是没通过什么,没通过编译,没通过考试?
代码没什么问题。