//从终端获取一个字符串,分别统计当中大写字母、小写字母、数字及其他字符的个数。 #include<stdio.h> #include<stdio.h> int main(int argc,const char *argv[]) { char str[100]; char ch; int len,i; int letter = 0, number = 0, space = 0, other = 0; gets(str); for(i=0;i<strlen(str);i++) { ch = str[i]; if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')) { letter++; } else if(ch>='0'&&ch<='9') { number++; } else if(ch==' ') { space++; } else { other++; } } printf("letter=%d\nnumber=%d\nspace=%d\nother=%d\n",letter,number,space,other); return 0; }