Advertisement
Spocoman

Darts

Sep 17th, 2023
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string name, zone;
  8.     getline(cin, name);
  9.     cin >> zone;
  10.  
  11.     int dots, yesCount = 0, noCount = 0, total = 301;
  12.  
  13.     while (zone != "Retire") {
  14.         cin >> dots;
  15.  
  16.         if (zone == "Double") {
  17.             dots *= 2;
  18.         }
  19.         else if (zone == "Triple") {
  20.             dots *= 3;
  21.         }
  22.  
  23.         if (total < dots) {
  24.             noCount++;
  25.         }
  26.         else {
  27.             total -= dots;
  28.             yesCount++;
  29.         }
  30.  
  31.         if (total == 0) {
  32.             break;
  33.         }
  34.  
  35.         cin >> zone;
  36.     }
  37.  
  38.     if (total == 0) {
  39.         cout << name << " won the leg with " << yesCount << " shots.\n";
  40.     }
  41.     else {
  42.         cout << name << " retired after " << noCount << " unsuccessful shots.\n";
  43.     }
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement