Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<iostream>#include<string>#include<vector>#include<cmath>using namespace std;int main(){string input = "", output = "";vector<int> letters(26);while(cin >> input){output = "";for(vector<int>::size_type ind = 0; ind < letters.size(); ++ind){letters[ind] = 0;}for(string::size_type ind = 0; ind < input.size(); ++ind){++letters[input[ind] - 'a'];}int lastInd = -1;bool found = false;int len = input.size();while(len--){found = false; // Remember to reset// Find the letters with max number to see if it exceeds ceil(len/2)int max = letters[0], selected = 0;for(string::size_type ind = 1; ind < letters.size(); ++ind){if(letters[ind] > max){max = letters[ind];selected = ind;}