From c5021432ab6fe706b84767a3c804f3dbefaf5af3 Mon Sep 17 00:00:00 2001 From: p7pykrxiq <1902838026@qq.com> Date: Tue, 15 Feb 2022 22:39:55 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E5=87=BD=E6=95=B0=20=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 函数 字符分类统计 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 函数 字符分类统计 diff --git a/函数 字符分类统计 b/函数 字符分类统计 new file mode 100644 index 0000000..d97ec28 --- /dev/null +++ b/函数 字符分类统计 @@ -0,0 +1,32 @@ +#include +void fun(char *s,int *a,int *b,int *c,int *d,int *e) +{ + int i=0,j=0,k=0,l=0,m=0; + while(*s){ + if(*s>='A'&&*s<='Z') + i++; + else if(*s>='a'&&*s<='z') + j++; + else if(*s>='0'&&*s<='9') + k++; + else if(*s==' ') + l++; + else + m++; + *s++; + } + *a=i; + *b=j; + *c=k; + *d=l; + *e=m; +} +int main( ) +{ + char s[100]; + int upper=0,lower=0,digit=0,blank=0,other=0; + gets(s); + fun (s,&upper,&lower,&digit,&blank,&other); + printf("upper=%d\nlower=%d\ndigit=%d\nblank=%d\nother=%d\n",upper,lower,digit,blank,other); + return 0; +} \ No newline at end of file