Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <sstream>
  4. #include <string>
  5. #include <cstring>
  6. #include <cstdio>
  7. #include <cstdlib>
  8. #include <functional>
  9. #include <numeric>
  10. #include <algorithm>
  11.  
  12. using namespace std;
  13.  
  14. int main() {
  15.     string str, s;
  16.     int sum = 0;
  17.  
  18.     while (getline(cin, str)) {
  19.         transform(str.begin(), str.end(), str.begin(), [](char c) { return isalpha(c) ? c : ' '; });
  20.  
  21.         istringstream is(str);
  22.  
  23.         while (is >> s) {
  24.             if (s == "tram") ++sum;
  25.             else if (s == "trolleybus") --sum;
  26.         }
  27.     }
  28.     if (sum < 0) cout << "Trolleybus driver" << endl;
  29.     else if (sum > 0) cout << "Tram driver" << endl;
  30.     else cout << "Bus driver" << endl;
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement