Advertisement
BojidarDosev

furniture

Apr 17th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int height, width, length;
  7. cin >> height >> width >> length;
  8.  
  9. long apartmentVolume = height * width * length;
  10.  
  11. long boxVolume;
  12. while (cin >> boxVolume)
  13. {
  14. if (boxVolume == -1) {
  15. cout << "Do I have space for my Audi A6? Space left: " << apartmentVolume << endl;
  16. return 0;
  17. }
  18.  
  19. if (apartmentVolume >= boxVolume) {
  20. apartmentVolume -= boxVolume;
  21. } else {
  22. cout << "No more space. You need " << (boxVolume - apartmentVolume) << " space more." << endl;
  23. return 0;
  24. }
  25. }
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement