Advertisement
myloyo

map1

Jun 7th, 2023 (edited)
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <string>
  6. #include <fstream>
  7. #include <sstream>
  8. #include <set>
  9. #include <map>
  10.  
  11. using namespace std;
  12. ifstream in("input.txt");
  13. ofstream out("output.txt");
  14.  
  15. int main() {
  16.     map<int, int> mc;
  17.     map <string, int> ms;
  18.     string s;
  19.     int ps = 0;
  20.     while (in >> s) {
  21.         bool f = 1;
  22.         for (auto x : s) {
  23.             if (!isdigit(x)) {
  24.                 f = 0;
  25.                 break;
  26.             }
  27.         }
  28.         if (f) {
  29.             mc[stoi(s)]++;
  30.             ps = stoi(s);
  31.         }
  32.         else {
  33.             ms[s]++;
  34.         }
  35.     }
  36.  
  37.     for (auto x : ms) {
  38.         if (x.second == mc[ps]) {
  39.             out << x.first << endl;
  40.         }
  41.     }
  42. }
  43.  
  44. soup soup soup soap soap 3 4 4 4 5 soap soap soup 4 skr skr karych liza skr popova skr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement