C++ Day1

思维导图:

C++ Day1_第1张图片

作业:

#include 
#include

using namespace std;

int main()
{
    int a=0,A=0,num=0,space=0,other=0;

    array str;
    array::iterator iter;

    cout << "请输入一个字符串:" << endl;
    for(iter = str.begin();iter != str.end();iter++)
    {
        cin >> *iter;
    }

    for(iter = str.begin();iter != str.end();iter++)
    {
//        cout << *iter << " ";
        if(int(*iter)>=97&&int(*iter)<=122)
        {
            a++;
        }
        else if(int(*iter)>=65&&int(*iter)<=90)
        {
            A++;
        }
        else if(int(*iter)>=48&&int(*iter)<=57)
        {
            num++;
        }
        else if(int(*iter)==32)
        {
            space++;
        }
        else
        {
            other++;
        }
    }

    cout << "小写:" << a << endl;
    cout << "大写:" << A << endl;
    cout << "数字:" << num << endl;
    cout << "空格:" << space << endl;
    cout << "其他:" << other << endl;

    return 0;
}

运行结果:

C++ Day1_第2张图片

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