#include <string>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int max_cnt=0,cnt=0;
string max_word,word,front_word;
while(cin>>word)
{
if(front_word.empty())
{
max_word=word;
front_word=word;
++cnt;
max_cnt=cnt;
}
else
{
if(front_word==word)
{
//max_word=word;
++cnt;
front_word=word;
if(max_cnt<cnt)
{
max_cnt=cnt;
max_word=word;
}
}
else
{
front_word=word;
cnt=1;
}
}
}
if(max_cnt>1)
cout<<"The "<<max_word<<" have "<<max_cnt<<" times."<<endl;
else
cout<<"no words more than two times."<<endl;
return 0;
}
c++ primer第五版练习5.14
最新推荐文章于 2022-05-13 22:20:27 发布