Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int main() {
- int startPoints, points;
- cin >> startPoints;
- cin.ignore();
- int moves = 0;
- while (startPoints > 0) {
- string command;
- getline(cin, command);
- moves++;
- if (command == "bullseye") {
- break;
- }
- cin >> points;
- cin.ignore();
- if (command == "double ring") {
- points *= 2;
- }
- else if (command == "triple ring") {
- points *= 3;
- }
- startPoints -= points;
- }
- if (startPoints == 0) {
- cout << "Congratulations! You won the game in " << moves << " moves!\n";
- }
- else if (startPoints < 0) {
- cout << "Sorry, you lost. Score difference: " << abs(startPoints) << ".\n";
- }
- else {
- cout << "Congratulations! You won the game with a bullseye in " << moves << " moves!\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement