#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{ char c;
int digit=0,block=0,others=0,letters=0;
printf("请输入长度小于100的字符");
while(c=getchar()!='\n')
{if((c>='a'&&c<='z')||(c>='A'&&c<='Z'))
letters++;
else if((c-'0')>=0&&(c-'0')<=9)
digit++;
else if(c==' ')
block++;
else
others++;
}
printf("%d%d%d%d",letters,digit,block,others);
system("pause");
return 0;
}
我想输入一些字符串,然后产生各个字符类型的个数,但是我写完这个代码后,发现,不管我输入什么字符,都是在others里加个数,非常奇怪