vector s;
string S;
int max = 1;
int bindex = 0, eindex = -1,index = 0;
while (cin >> S)
{
s.push_back(S);
++eindex;
if(eindex>bindex)
if (s[bindex] != s[eindex])
{
if (eindex - bindex > max)
{
max = eindex - bindex;
index = bindex;
}
bindex = eindex;
}
}
cout << "出现最多的单词" << s[index] << "出现了" << max << "次" << endl;
while循环里是cin>>s,使用ctrl z 回车 结束,但是结束的一瞬间就看不到结果了。。所以我想知道代码对不对。。