相邻重复字符数目最大者
#include#include #include <string> #include #include 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< endl; return 0; }