From 1233c52fe1314b7ab24b9af8166caa427572b40e Mon Sep 17 00:00:00 2001 From: pi2o8m7nv <985803854@qq.com> Date: Sun, 20 Feb 2022 11:47:15 +0800 Subject: [PATCH] ADD file via upload --- 字符分类统计.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 字符分类统计.c 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; + }