#include <iostream>
using namespace std;
int main()
{
string str;
cout << "please input a string:";
getline(cin, str);
cout << str << endl;
int count_low = 0, count_big = 0, count_num = 0, count_space = 0, count_other = 0;
cout << str << endl;
int len = str.size();
for(int i = 0; i < len; i++)
{
if (str[i] >= 'a' && str[i] <= 'z')
count_low++;
else if (str[i] >= 'A' && str[i] <= 'Z')
count_big++;
else if (str[i] >= '0' && str[i] <= '9')
count_num++;
else if (str[i] == ' ')
count_space++;
else
count_other++;
}
cout << "小写字母有" << count_low << endl;
cout << "大写字母有" << count_big << endl;
cout << "数字有" << count_num << endl;
cout << "空格有" << count_space << endl;
cout << "其他字符有" << count_other << endl;
return 0;
}
10-21
6983
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)