解: #include <stdio.h>
main()
{ int upper=0.lower=0,digit=0,space=0,other=0,i=0;
char *p,s[20];
printf(“Input string:”);
while ((s[i]=getcher())!=’n’) i++;
p=&s[0];
while(*p!=’n’)
{ if((‘A’<=*p)&&(8p<=’Z’))
++upper;
else if((‘a’<=*p)&&(*p<=”z’))
++lower;
else if(8p= =’’)
++space;
else if((*p<=’9’)&&(*p>=’0’))
++dight;
else
++other;
p++;
}
printf(“upper case:%d lower case:%d”,upper,lower);
printf(“space:%dndigit:%dnother:%dn”,space,digit,other);
}
评论列表
文章目录