Advertisement
Spocoman

Basketball Tournament

Sep 15th, 2023 (edited)
1,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string tournament;
  8.     getline(cin, tournament);
  9.  
  10.     int won = 0, lost = 0, games, team1, team2;
  11.  
  12.     while (tournament != "End of tournaments") {
  13.         cin >> games;
  14.  
  15.         for (int game = 1; game <= games; game++) {
  16.             cin >> team1 >> team2;
  17.             if (team1 > team2) {
  18.                 cout << "Game " << game << " of tournament " << tournament << ": win with " << team1 - team2 << " points.\n";
  19.                 won++;
  20.             }
  21.             else {
  22.                 cout << "Game " << game << " of tournament " << tournament << ": lost with " << team2 - team1 << " points.\n";
  23.                 lost++;
  24.             }
  25.         }
  26.  
  27.         cin.ignore();
  28.         getline(cin, tournament);
  29.     }
  30.  
  31.     printf("%.2f%% matches win\n", 1.0 * won / (won + lost) * 100);
  32.     printf("%.2f%% matches lost\n", 1.0 * lost / (won + lost) * 100);
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement