Advertisement
Spocoman

Cat Shelter

Sep 16th, 2023
700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int food;
  8.     cin >> food;
  9.  
  10.     food *= 1000;
  11.  
  12.     string command;
  13.     cin >> command;
  14.  
  15.     while (command != "Adopted") {
  16.         food -= stoi(command);
  17.         cin >> command;
  18.     }
  19.  
  20.     if (food >= 0){
  21.         cout << "Food is enough! Leftovers: " << food << " grams.\n";
  22.     }
  23.     else{
  24.         cout << "Food is not enough. You need " << abs(food) << " grams more.\n";
  25.     }
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement