Advertisement
Spocoman

Best Player

Sep 15th, 2023
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string command, bestPlayer;
  8.     getline(cin, command);
  9.  
  10.     int currentPlayerGoals, bestPlayerGoals = 0;
  11.  
  12.     while (command != "END" && bestPlayerGoals < 10) {
  13.         string currentPlayer = command;
  14.         cin >> currentPlayerGoals;
  15.  
  16.         if (currentPlayerGoals > bestPlayerGoals) {
  17.             bestPlayer = currentPlayer;
  18.             bestPlayerGoals = currentPlayerGoals;
  19.         }
  20.  
  21.         cin.ignore();
  22.         getline(cin, command);
  23.     }
  24.    
  25.     cout << bestPlayer<< " is the best player!\n";
  26.  
  27.     if (bestPlayerGoals < 3) {
  28.         cout << "He has scored " << bestPlayerGoals << " goals.\n";
  29.     }
  30.     else{
  31.         cout << "He has scored " << bestPlayerGoals << " goals and made a hat-trick !!!\n";
  32.     }
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement