From d91dbe1adceaed219fc4cee71a730d58cd34b947 Mon Sep 17 00:00:00 2001 From: pn43tqvrm <2516333959@qq.com> Date: Sat, 19 Feb 2022 17:21:28 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E5=AD=97=E7=AC=A6=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 字符类型统计 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 字符类型统计 diff --git a/字符类型统计 b/字符类型统计 new file mode 100644 index 0000000..4933c0c --- /dev/null +++ b/字符类型统计 @@ -0,0 +1,24 @@ +#include +#include +int main() +{ + char str[100]; + int n, a = 0, b = 0, c = 0, d = 0, e = 0; + gets(str); + n = strlen(str); + for(int i = 0; i < n; i ++) + { + if(str[i] >='A' && str[i] <= 'Z') + a ++; + else if(str[i] >= 'a' && str[i] <= 'z') + b ++; + else if(str[i] >= '0' && str[i] <= '9') + c ++; + else if(str[i] == ' ') + d ++; + else + e ++; + } + printf("capital letters:%d\nsmall letters:%d\nblank spaces:%d\nnumbers:%d\nother:%d", a, b, d, c, e); + return 0; +} \ No newline at end of file