Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. string str, s;
  9. int sum = 0;
  10.  
  11. while (getline(cin, str)){
  12. for (int i = str.size() - 1; i >= 0; --i)
  13. if (!((str[i] <= 'z' && str[i] >= 'a') || (str[i] <= 'Z' && str[i] >= 'A')))
  14. str[i] = ' ';
  15.  
  16. istringstream is(str);
  17.  
  18. while (is >> s){
  19. if (s == "tram") ++sum;
  20. else if (s == "trolleybus") --sum;
  21. }
  22. }
  23. if (sum < 0) cout << "Trolleybus driver" << endl; else
  24. if (sum > 0) cout << "Tram driver" << endl;
  25. else cout << "Bus driver" << endl;
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement