Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int height_of_cake, width_of_cake;
- cin >> width_of_cake >> height_of_cake;
- int number_of_pieces = width_of_cake * height_of_cake;
- string current_input;
- cin >> current_input;
- bool cake_is_over = false;
- while (current_input != "STOP")
- {
- int current_pieces_to_take = stoi(current_input);
- if (current_pieces_to_take > number_of_pieces)
- {
- cake_is_over = true;
- int needed_pieces = current_pieces_to_take - number_of_pieces;
- cout << "No more cake left! You need "
- << needed_pieces
- << " pieces more."
- << endl;
- break;
- }
- else
- {
- number_of_pieces -= current_pieces_to_take;
- }
- cin >> current_input;
- }
- if (!cake_is_over)
- {
- cout << number_of_pieces << " pieces are left." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement