Advertisement
DidiMilikina

Задача 02 - Тръби в басейн

Oct 25th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. int main() {
  8.     long pool_volume;
  9.     long pipe_1;
  10.     long pipe_2;
  11.     double hours;
  12.  
  13.     cin >> pool_volume >> pipe_1 >> pipe_2 >> hours;
  14.  
  15.     double pipe_1_filled = pipe_1 * hours;
  16.     double pipe_2_filled = pipe_2 * hours;
  17.     double current_volume = pipe_1_filled + pipe_2_filled;
  18.     double pipe_1_percentage = (pipe_1_filled / current_volume) * 100;
  19.     double pipe_2_percentage = (pipe_2_filled / current_volume) * 100;
  20.     double current_volume_percentage = (current_volume / pool_volume) * 100;
  21.     double overflow = current_volume - pool_volume;
  22.  
  23.     if (current_volume <= pool_volume)
  24.     {
  25.         cout << "The pool is " << floor(current_volume_percentage) << "% full. Pipe 1: "
  26.             << floor(pipe_1_percentage) << "%. Pipe 2: " << floor(pipe_2_percentage) << "%." << endl;
  27.     }
  28.     else if (current_volume > pool_volume)
  29.     {
  30.         cout << "For " << hours << " hours the pool overflows with " << fixed << setprecision(1) << overflow << " liters." << endl;
  31.     }
  32.    
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement