#include<iostream.h>
void main()
{
int m,n,x,y,j;
m=0;n=0;y=0;x=0;
char a[5];
cin>>a;
for(j=0;j<=4;j++)
{if (a[j]>='a' && a[j]<='z')
m+=1;
else if (a[j]>='A' && a[j]<='Z')
n+=1;
else if (a[j]>='0' && a[j]<='9')
x+=1;
else y+=1;
}
cout<<"a~z="<<m<<" "<<"A~Z="<<n<<" "<<"0~9="<<x<<" "<<"another="<<y<<endl;
}
和上一个实现的工能一样,只是我决的键盘输入太麻烦了,要是输入大量的字符呢?
所以我改变了编法,你可以在一行输写了,不用打一个字符,打一下回车了?
哈哈!