#include<stdio.h>
#include<string.h>
int main(void)
{
char s[100],*p=s;
int m;
int bnum=0;
int snum=0;
int dnum=0;
int onum=0;
printf("请输入一个字符串:\n");
gets(s);
m=strlen(s);
for(int i=0;i<m;i++)
{
if(s[i]>='A'&&s[i]<='Z')
bnum++;
else if(s[i]>='a'&&s[i]<='z')
snum++;
else if(s[i]>='0'&&s[i]<='9')
dnum++;
else
onum++;
}
printf("%d %d %d %d",bnum,snum,dnum,onum);
return 0;
}
#include<stdio.h>
int main(void)
{
char s[100],*p=s;
int num,upper,lower,other;
num=upper=lower=other=0;
printf("Please input enter a string: ");
gets(s);
while(*p != '\0')
{
if( *p >='0'&& *p <= '9')
num++;
else if( *p >= 'a' && *p <= 'z')
lower++;
else if( *p >= 'A' && *p <= 'Z')
upper++;
else other++;
p++;
}
printf("num=%d,upper=%d,lower=%d,other=%d",num,upper,lower,other);
return 0;
}