解题思路:
注意事项:空格要用2个==号 不然不会输出others的内容
参考代码:
#include<stdio.h>
int main()
{
int digit,others,alph,kong;
char ch;
digit=others=alph=kong=0;
ch=getchar();
while(ch!='\n')
{
if(ch>='0'&&ch<='9')
{
digit++;
}
else if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
{
alph++;
}
else if(ch==32)
{
kong++;
}
else
{
others++;
}
ch=getchar();
}
printf("%d %d %d %d",alph,digit,kong,others);
return 0;
}
0.0分
0 人评分