Advertisement
mark79

Darts Tournament

Feb 22nd, 2020
235
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. #include <string>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int points;
  9.     cin >> points;
  10.     cin.ignore();
  11.  
  12.     int totalThrows = 0;
  13.     while (points > 0) {
  14.         totalThrows++;
  15.         string sector;
  16.         getline(cin, sector);
  17.  
  18.  
  19.         if (sector == "bullseye") {
  20.             cout << "Congratulations! You won the game with a bullseye in " << totalThrows << " moves!";
  21.             return 0;
  22.         }
  23.         int hitPoints;
  24.         cin >> hitPoints;
  25.         cin.ignore();
  26.  
  27.         //if (sector == "number section") {
  28.         //    hitPoints *= 1;
  29.         //}else
  30.  
  31.         if (sector == "double ring") {
  32.             hitPoints *= 2;
  33.         }
  34.         else if (sector == "triple ring") {
  35.             hitPoints *= 3;
  36.         }
  37.  
  38.         points -= hitPoints;
  39.     }
  40.     if (points == 0) {
  41.         cout << "Congratulations! You won the game in " << totalThrows << " moves!";
  42.     }
  43.     else {
  44.         cout << "Sorry, you lost. Score difference: " << abs(points) << ".";
  45.     }
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement