Advertisement
kolioi

Тръби в басейн C++

Sep 29th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     using namespace std;
  6.  
  7.     int V, P1, P2;
  8.     double H;
  9.  
  10.     cin >> V >> P1 >> P2 >> H;
  11.  
  12.     double V1 = P1 * H,
  13.            V2 = P2 * H;
  14.  
  15.     if (V1 + V2 <= V)
  16.     {
  17.         int x = (int)((V1 + V2) * 100.0 / V),
  18.             y = (int)(V1 * 100.0 / (V1 + V2)),
  19.             z = (int)(V2 * 100.0 / (V1 + V2));
  20.         cout << "The pool is " << x << "% full. Pipe 1: " << y << "%. Pipe 2: " << z << "%." << endl;
  21.     }
  22.     else
  23.     {
  24.         cout << "For " << H << " hours the pool overflows with ";
  25.         cout.precision(1);
  26.         cout << fixed << V1 + V2 - V << " liters." << endl;
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement