Advertisement
Spocoman

07. Moving

Sep 11th, 2023
648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int width, length, height;
  8.     cin >> width >> length >> height;
  9.  
  10.     int freeSpace = width * length * height;
  11.  
  12.     string box;
  13.  
  14.     while (freeSpace > 0) {
  15.         cin >> box;
  16.  
  17.         if (box == "Done") {
  18.             break;
  19.         }
  20.  
  21.         freeSpace -= stoi(box);
  22.     }
  23.  
  24.     if (box == "Done") {
  25.         cout << freeSpace << " Cubic meters left.\n";
  26.     }
  27.     else {
  28.         cout << "No more free space! You need " << abs(freeSpace) << " Cubic meters more.";
  29.     }
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement