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