From d00dffb5a42787a00c991d4e11f6f1a0622d9d43 Mon Sep 17 00:00:00 2001 From: pql5ifepn <2149851645@qq.com> Date: Wed, 23 Feb 2022 20:36:08 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 字符串分类统计 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 字符串分类统计 diff --git a/字符串分类统计 b/字符串分类统计 new file mode 100644 index 0000000..faf6864 --- /dev/null +++ b/字符串分类统计 @@ -0,0 +1,26 @@ +#include +void Count(char ch[]) +{ + int n1, n2, n3, n4, n5, i; + for(i = 0; i < 10; i ++) + { + if(ch[i] >= 'A' && ch[i] <= 'Z') + n1 ++; + else if(ch[i] >= 'a' && ch[i] <= 'z') + n2 ++; + else if(ch[i] >= '0' && ch[i] <= '9') + n3 ++; + else if(ch[i] == ' ') + n4 ++; + else + n5 ++; + } + printf("%d %d %d %d %d", n1, n2, n3, n4, n5); +} +int main() +{ + char ch[10]; + gets(ch); + Count(ch); + return 0; +} \ No newline at end of file