输入一行字符,分别统计其中英文字母、空格、数字和其他字符的个数。
#include <stdio.h>
int main(){
int english,blank,number,other;
english=blank=number=other=0;
char c;
printf("请输入一行字符:\n");
while((c=getchar())!='\n'){
if(c>='a'&&c<='z'||c>='A'&&c<='Z'){
english++;
}
if(c==' '){
blank++;
}
if(c>='0'&&c<='9'){
number++;
}
else{
other++;
}
}
printf("英文字母有%d个,空格有%d个,数字有%d个,其他字符有%d个",english,blank,number,other);
}