10.07hw

10.07hw_第1张图片10.07hw_第2张图片10.07hw_第3张图片

int main()
{
    string str;
    cout << "输入字符串:";
    getline(cin,str);
    int size =str.size();
    int big = 0;
    int small = 0;
    int num = 0;
    int space = 0;
    int other = 0;
    for(int i=0;i='A')
        {
            big++;
        }
        else if(str[i]<='z'&&str[i]>='a')
        {
            small++;
        }
        else if(str[i]<='9'&&str[i]>='0')
        {
            num++;
        }
        else if(str[i]==' ')
        {
            space++;
        }
        else
            other++;
    }
    cout << "big=" << big << endl;
    cout << "small=" << small << endl;
    cout << "num=" << num << endl;
    cout << "space=" << space <

你可能感兴趣的:(c++,算法,开发语言)