Advertisement
Spocoman

Tennis Ranklist

Sep 22nd, 2023
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int numberOfTournaments, startPoints;
  7.     cin >> numberOfTournaments >> startPoints;
  8.  
  9.     int tournamentPoints = 0;
  10.     int gamesWon = 0;
  11.  
  12.     string currentTournament;
  13.  
  14.     for (int i = 0; i < numberOfTournaments; i++) {
  15.         cin >> currentTournament;
  16.  
  17.         if (currentTournament == "W") {
  18.             tournamentPoints += 2000;
  19.             gamesWon++;
  20.         } else if (currentTournament == "F") {
  21.             tournamentPoints += 1200;
  22.         }
  23.         else {
  24.             tournamentPoints += 720;
  25.         }
  26.     }
  27.  
  28.     cout.setf(ios::fixed);
  29.     cout.precision(2);
  30.  
  31.     cout << "Final points: " << startPoints + tournamentPoints << endl;
  32.     cout << "Average points: " << tournamentPoints / numberOfTournaments << endl;
  33.     cout << 100.0 * gamesWon / numberOfTournaments << '%' << endl;
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement