Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <string>
- #include <vector>
- using namespace std;
- bool u (string e, string q)
- {
- for(int i = 0; i < min(e.size(), q.size()); i++)
- {
- if(e[i] > q[i])
- {
- return true;
- }
- else if(e[i] < q[i])
- {
- return false;
- }
- }
- if(e.size() > q.size())
- return false;
- else
- {
- return true;
- }
- }
- int main()
- {
- string a;
- getline(cin, a);
- a += " ";
- map < string, int > m;
- int ma = -99999;
- string mas;
- string w = "";
- for(int i = 0; i < a.size(); i++)
- {
- if(a[i] == ' ')
- {
- m[w]++;
- if(m[w] > ma)
- {
- ma = m[w];
- mas = w;
- }
- if(m[w] == ma)
- {
- if(u(mas, w))
- {
- mas = w;
- }
- }
- w = "";
- }
- else
- {
- w += a[i];
- }
- }
- cout << mas;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement