Advertisement
Spocoman

Suitcases Load

Sep 22nd, 2023 (edited)
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     double availableArea;
  7.     cin >> availableArea;
  8.  
  9.     string suitcaseVolume;
  10.     cin >> suitcaseVolume;
  11.  
  12.     int loadedSuitcases = 0;
  13.  
  14.     while (suitcaseVolume != "End") {
  15.           double currentSuitcaseVolume = stod(suitcaseVolume);
  16.  
  17.         if (++loadedSuitcases % 3 == 0) {
  18.             currentSuitcaseVolume *= 1.1;
  19.         }
  20.  
  21.         if (currentSuitcaseVolume > availableArea) {
  22.             loadedSuitcases--;
  23.             break;
  24.         }
  25.         availableArea -= currentSuitcaseVolume;
  26.        
  27.         cin >> suitcaseVolume;
  28.     }
  29.  
  30.     if (suitcaseVolume == "End") {
  31.         cout << "Congratulations! All suitcases are loaded!\n";
  32.     }
  33.     else {
  34.         cout << "No more space!\n";
  35.     }
  36.     cout << "Statistic: " << loadedSuitcases << " suitcases loaded.\n";
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement