Advertisement
Spocoman

Tournament of Christmas

Sep 22nd, 2023 (edited)
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int days, winTotal = 0, loseTotal = 0;
  8.     cin >> days;
  9.  
  10.     string command;
  11.     double totalSum = 0;
  12.  
  13.     for (int i = 0; i < days; i++) {
  14.         int win = 0, lose = 0;
  15.         double sum = 0;
  16.  
  17.         while (true) {
  18.             cin >> command;
  19.             if (command == "win") {
  20.                 sum += 20;
  21.                 win++;
  22.             }
  23.             else if (command == "lose") {
  24.                 lose++;
  25.             }
  26.             else if (command == "Finish") {
  27.                 if (win > lose) {
  28.                     totalSum += sum * 1.1;
  29.                     winTotal += win;
  30.                 }
  31.                 else {
  32.                     totalSum += sum;
  33.                     loseTotal += lose;
  34.                 }
  35.                 break;
  36.             }
  37.         }
  38.     }
  39.  
  40.     cout.setf(ios::fixed);
  41.     cout.precision(2);
  42.  
  43.     if (winTotal > loseTotal) {
  44.         cout << "You won the tournament! Total raised money: " << totalSum * 1.2 << endl;
  45.     }
  46.     else {
  47.         cout << "You lost the tournament! Total raised money: " << totalSum << endl;
  48.     }
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement