- #include
-
- using namespace std;
-
- int main()
- {
- cout << "请输入一个字符串" << endl;
- string str;
- getline(cin,str);
- int capital = 0;
- int lower = 0;
- int numb = 0;
- int other = 0;
- int size = str.size();
- for(int i=0;i
- {
- if(str.at(i) >= 'A' && str.at(i) <= 'Z')
- {
- capital++;
- }
- else if(str.at(i) >= 'a' && str.at(i) <= 'z')
- {
- lower++;
- }
- else if(str.at(i) >= '0' && str.at(i) <= '9')
- {
- numb++;
- }
- else
- {
- other++;
- }
-
-
- }
- cout << "大写字母:" << capital << endl;
- cout << "小写字母:" << lower << endl;
- cout << "数字:" << numb << endl;
- cout << "其他字符" << other << endl;
-
- return 0;
- }
思维导图