Advertisement
vlatkovski

Anketa

Sep 17th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <utility>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     int n;
  10.     cin >> n;
  11.  
  12.     vector<pair<string,int>> iminja; //bi koristel set ama ima 100 iminja maksimum, pa ne mora
  13.  
  14.     int najveke = -1;
  15.     string imeto = "";
  16.  
  17.     for (int i = 0; i < n; i++) {
  18.         string ime;
  19.         cin >> ime;
  20.  
  21.         bool najdeno = false;
  22.  
  23.         for (unsigned int x = 0; x < iminja.size(); x++) {
  24.             if (iminja[x].first == ime) {
  25.                 najdeno = true;
  26.  
  27.                 int broj = iminja[x].second;
  28.                 iminja[x].second++;
  29.  
  30.                 if (broj > najveke) {
  31.                     imeto = ime;
  32.                     najveke = broj;
  33.                 }
  34.  
  35.                 break;
  36.             }
  37.         }
  38.  
  39.         if (!najdeno) {
  40.             iminja.push_back({ime, 1});
  41.         }
  42.  
  43.     }
  44.  
  45.     cout << imeto << endl;
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement