Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- int foodInKilograms;
- cin >> foodInKilograms;
- int availableFoodInGrams = foodInKilograms * 1000;
- string command;
- cin >> command;
- while (command != "Adopted") {
- availableFoodInGrams -= stoi(command);
- cin >> command;
- }
- if (availableFoodInGrams >= 0) {
- printf("Food is enough! Leftovers: %i grams.", availableFoodInGrams);
- }
- else {
- printf("Food is not enough. You need %i grams more.", abs(availableFoodInGrams));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement