#include <iostream> #include <vector> #include <string> #include <cstring> #include <bitset> using namespace std; int main() { string str,prestr,restr; int cnt=0,max=1; while (cin>>str) { if (prestr==str) { ++cnt; } else { if (cnt>max) { restr=prestr; max=cnt; } cnt=1; } prestr=str; } if (max<cnt) { max=cnt; restr=str; } cout<<restr<<max<<endl; return 0; }
原文:http://www.cnblogs.com/xiaodi914/p/5674679.html