daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <algorithm>
  5. #include <functional>
  6. using namespace std;
  7.  
  8.  
  9.  
  10. int main()
  11. {
  12.     int school [100] = {};
  13.     short count;
  14.     ifstream fin("input.txt");
  15.     {
  16.  
  17.         string line;
  18.         string str1;
  19.         string str2;
  20.  
  21.         int num;
  22.         bool b = true;
  23.         while (b)
  24.         {
  25.             getline(fin, line);
  26.             if(line == "")
  27.             {
  28.                 b = false;
  29.             }
  30.             else
  31.             {
  32.  
  33.             stringstream x;
  34.             x << line;
  35.             x >> str1 >> str2 >> num >> count;
  36.             school[num]++;
  37.  
  38.             }
  39.         }
  40.     }
  41.     fin.close();
  42.     int max = 0;
  43.     for(int i = 1; i<=99 ; i++)
  44.     {
  45.         if(school[i] > max)
  46.         {
  47.             max = school[i];
  48.         }
  49.     }
  50.     ofstream fout("output.txt");
  51.    count = 0;
  52.     for(int i = 1; i<100 ; i++)
  53.     {
  54.         if(school[i] == max  )
  55.         {
  56.             if(count == 0) {
  57.                 count++;
  58.                 fout << i;
  59.             }
  60.             else
  61.                 {
  62.                     fout << ' '<< i;
  63.             }
  64.         }
  65.     }
  66.  
  67.     fout.close();
  68.     return 0;
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top