从键盘中输入一组字符,统计其中大写字母的个数、小写字母的个数和数字字符的个数。
#include<iostream>
#include<cstring>
using namespace std;
char a[200];
int main() {
int t1=0,t2=0,t3=0;
//t1,t2,t3表示大写字母、小写字母、数字的个数
cin.getline(a,200);
int len=strlen(a);
for(int i=0; i<len; i++) {
if(a[i]>='A'&&a[i]<='Z')
t1++;
else if(a[i]>='a'&&a[i]<='z')
t2++;
else if(a[i]>='0'&&a[i]<='9')
t3++;
}
cout<<t1<<" "<<t2<<" "<<t3<<endl;
return 0;
}