c++ primer 练习5.14

来源:互联网 发布:甲骨文java认证 编辑:程序博客网 时间:2024/05/21 17:01
#include <iostream>#include <vector>using namespace std;int main(){    int cur = 1, max = 0;    string str, maxStr = "", curStr = "";    vector<string> st;    while (cin >> str) {        st.push_back(str);    }    auto beg = st.begin();    while (beg != st.end()) {        if (*beg == curStr) {            ++cur;            cout << 111 << endl;        } else {            cur = 1;            curStr = *beg;        }        if (cur > max) {            max = cur;            maxStr = curStr;        }        ++beg;    }    cout << "maxStr: " + maxStr << "  " << max << endl;    return 0;}

0 0
原创粉丝点击