相邻重复字符数目最大者
#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; }
积极乐观,好好coding