/*输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数*/ #include<stdio.h> #include<ctype.h> int main(void) { char s[100],*p=s; int a=0,b=0,c=0,d=0; gets(s); while(*p) { if(isalpha(*p)) a++; else if(*p==32) b++; else if(isdigit(*p)) c++; else d++; p++; } printf("%d\n%d\n%d\n%d",a,b,c,d); return 0; }
解题思路:
注意事项:
参考代码:
0.0分
0 人评分