Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- int energy, count = 0, battleIndex;
- cin >> energy;
- cin.ignore();
- string command;
- getline(cin, command);
- while (command != "End of battle") {
- battleIndex = stoi(command);
- if (energy < battleIndex) {
- break;
- }
- count++;
- if (count % 3 == 0) {
- energy += count;
- }
- energy -= battleIndex;
- getline(cin, command);
- }
- if (command == "End of battle") {
- cout << "Won battles: " << count << ". Energy left: " << energy << endl;
- }
- else {
- cout << "Not enough energy! Game ends with " << count << " won battles and " << energy << " energy\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement