#include "stdio.h"
int main(int argc,char *argv[]){
char ch;
int uc,lc,di,oh;
uc=lc=di=oh=0;
printf("Please enter a string('q'/'Q' end)...\n");
while(scanf(" %c",&ch)==1){
if(ch>='A' && ch<='Z')
uc++;
else if(ch>='a' && ch<='z')
lc++;
else if(ch>='0' && ch<='9')
di++;
else
oh++;
if(ch=='q' || ch=='Q')
break;
}
printf("Uppercase:\t%d\nLowercase:\t%d\n Numbers:\t%d\n Other:\t%d\n",uc,lc,di,oh);
return 0;
}
运行样例: