Add 函数 字符分类统计

master
p7pykrxiq 3 years ago
parent 82f4f06cb1
commit c5021432ab

@ -0,0 +1,32 @@
#include <stdio.h>
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;
}
Loading…
Cancel
Save