#include <iostream>
#include <array>
using namespace std;
int main()
{
cout<<"请输入一个字符串"<<endl;
//array<string,100> str;
string str;
getline(cin,str);
int daxie=0,xiaoxie=0,num=0,space=0,other=0;
int len=str.size();
;
for(int i=0;i<len;i++)
{
if(str[i]>='A'&&str[i]<='Z')
{
daxie++;
}else if(str[i]>='a'&&str[i]<='z')
{
xiaoxie++;
}else if(str[i]>='0'&&str[i]<='9')
{
num++;
}else if(str[i]==' ')
{
space++;
}else
{
other++;
}
}
cout<<"大写字母个数是"<<daxie<<endl;
cout<<"小写字母个数是"<<xiaoxie<<endl;
cout<<"数字个数是"<<num<<endl;
cout<<"空格个数是"<<space<<endl;
cout<<"其他字符个数是"<<other<<endl;
return 0;
}
运行结果: