Advertisement
srtgguy

Untitled

May 23rd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string word;
  9.     getline(cin, word);
  10.     string ww = word.substr(0, 1);
  11.     int z = 0, y = 0;
  12.     for (int i = 0; i < word.size(); i++)
  13.     {
  14.         for (int k = 0; k < word.size(); k++)
  15.         {
  16.             if (word.substr(i, 1) == word.substr(k, 1))
  17.             {
  18.                 y += 1;
  19.             }
  20.         }
  21.         if (y > z)
  22.         {
  23.             z = y;
  24.             ww = word.substr(i, 1);
  25.         }
  26.         y = 0;
  27.     }
  28.     cout << ww;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement