Advertisement
DidiMilikina

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

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