193030

Bottle Volume, not finished

Mar 31st, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. // primeren input:
  2. // 3 // 3 testa
  3. // 1 20 // panica 1 = 20
  4. // 2 30 //
  5. // 3 50 //
  6. // OUTPUT: 100
  7. //
  8.  
  9.  
  10. #include <iostream>
  11. #include <string>
  12. #include <cstdlib>
  13. #include <sstream>      // std::stringstream
  14.  
  15. using namespace std;
  16.  
  17.  
  18.  
  19. int a = 5;
  20. int b = 7;
  21. int x = 2;
  22. int currentMivkaVol = 0;
  23. int need,sinkCounter, bottleCounter =0;
  24. int currentVolume =0;
  25. int bottleVolume = a;
  26. int main() {
  27.   bottleCounter = 1;
  28.   while(1)
  29.   {
  30.     need = b-currentVolume;
  31.     if(need >= bottleVolume)
  32.     {
  33.         currentVolume +=bottleVolume;
  34.         bottleVolume-=bottleVolume;
  35.     }
  36.     if(need <= bottleVolume)
  37.     {
  38.        currentVolume += need;
  39.        bottleVolume = bottleVolume - need;
  40.     }
  41.  
  42.     if(currentVolume == b)
  43.     {
  44.         currentVolume =0;
  45.         sinkCounter++;
  46.  
  47.     }
  48.     if(bottleVolume ==  0)
  49.     {
  50.         bottleVolume = a;
  51.         bottleCounter++;
  52.      }
  53.     if(bottleVolume ==  x) break;
  54.  
  55.  
  56.   }
  57.     cout << bottleCounter << endl;
  58.     cout << sinkCounter++ << endl;
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment