Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
67f4753114 | 4 years ago |
@ -0,0 +1,30 @@
|
||||
//字符分类统计
|
||||
#include<stdio.h>
|
||||
#define N 10
|
||||
void fun(char ch[])
|
||||
{
|
||||
int a=0,b=0,c=0,d=0,e=0;
|
||||
for(int i=0;i<N;i++)
|
||||
{
|
||||
if(ch[i]>='A'&&ch[i]<='Z')
|
||||
a++;
|
||||
else if(ch[i]>='a'&&ch[i]<='z')
|
||||
b++;
|
||||
else if(ch[i]>='0'&&ch[i]<='9')
|
||||
c++;
|
||||
else if(ch[i]==' ')
|
||||
d++;
|
||||
else
|
||||
e++;
|
||||
}
|
||||
printf("%d %d %d %d %d",a,b,c,d,e);
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int i;
|
||||
char ch[N];
|
||||
for(i=0;i<N;i++)
|
||||
scanf("%c",&ch[i]);
|
||||
fun(ch);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue