diff --git a/字符分类统计.c b/字符分类统计.c new file mode 100644 index 0000000..8847792 --- /dev/null +++ b/字符分类统计.c @@ -0,0 +1,26 @@ +#include + +void StringCount( char s[] ) +{ + int a=0,b=0,c=0,d=0,e=0,i; + + for(i=0;s[i]!='\0';i++) + { + if('A'<=s[i]&&s[i]<='Z') a++; + else if('a'<=s[i]&&s[i]<='z') b++; + else if(s[i]==' '||s[i]=='\n') c++; + else if('0'<=s[i]&&s[i]<='9') d++; + else e++; + } + printf("%d %d %d %d %d",a,b,d,c,e); +} + + + +int main() +{ + char s[10]; + gets(s); + StringCount(s); + return 0; + }