#include<stdio.h> #include<string.h> int main() { char str[105]; int i,k,a,b,c,d; a=0;b=0;c=0;d=0;//变量初始化 gets(str); k=strlen(str);//统计字符数组的长度,注意头文件 for(i=0;i<k;i++){ if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z')){ a++; } else if(str[i]==' '){ b++; } else if(str[i]>='0'&&str[i]<='9'){ c++; } else{ d++;//逐个统计 } } printf("%d\n%d\n%d\n%d\n",a,b,c,d);//按顺序打印 return 0; }
0.0分
0 人评分