2023.10.07

2023.10.07_第1张图片

#include 

using namespace std;

int main()
{
    string str;
    cout << "请输入字符串:";
    getline(cin,str);
    int big=0,little=0,spac=0,num=0,sym=0;
    int size=str.size();
    for(int i=0;i65){
            big++;
        }
        if((int)str.at(i)<97+26 && (int)str.at(i)>97){
            little++;
        }
        if(str.at(i)>'0' && str.at(i)<'9'){
            num++;
        }
        if(' '==str.at(i)){
            spac++;
        }
    }
    cout << "big= " << big << " ";
    cout << "little= " << little << " ";
    cout << "spac= " << spac << " ";
    cout << "num= " << num << " ";
    cout << "sym= " << str.size()-big-little-spac-num << " ";
    cout << endl;
    return 0;
}

2023.10.07_第2张图片

2023.10.07_第3张图片

你可能感兴趣的:(算法,c++,数据结构)