GastonFontenla

Timus: 1612 - Tram Forum

Jun 5th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     string s;
  10.  
  11.     map<string, int> mapa;
  12.  
  13.     while(getline(cin, s))
  14.     {
  15.         for(int i=0; i<s.size(); i++)
  16.             if(!(s[i] >= 'a' && s[i] <= 'z'))
  17.                 s[i] = ' ';
  18.         stringstream ss;
  19.         ss << s;
  20.         while(ss >> s)
  21.             mapa[s]++;
  22.     }
  23.  
  24.     int tram = mapa["tram"];
  25.     int trol = mapa["trolleybus"];
  26.  
  27.     if(tram == trol)
  28.         cout << "Bus driver" << endl;
  29.     else if(tram > trol)
  30.         cout << "Tram driver" << endl;
  31.     else
  32.         cout << "Trolleybus driver" << endl;
  33.  
  34.     return 0;
  35. }
Add Comment
Please, Sign In to add comment