c++ primer 练习5.21

来源:互联网 发布:多巴胺检测知乎 编辑:程序博客网 时间:2024/06/05 10:01

/**   * c++ primer 5.21*   **/      #include <iostream>    #include <vector>    using namespace std;            int main()    {         //  qwe qsd axcv fgds fhfgh q e rt q e rt ASX AZS aSQ Qa Qa    string buf, mstr;    vector<string> str;    bool status = false;    while (cin >> buf && !status) {        if (buf[0] < 'A' || buf[0] > 'Z') {            continue;        }        for (auto i : str) {            if (i == buf) {                mstr = buf;                status = true;                break;            }        }        str.push_back(buf);    }    if (status) {        cout << "首字母大写并且重复出现的单词是:" + mstr << endl;    } else {        cout << "没有任何单词是连续重复出现的" << endl;    }    return 0;}


0 0