SHARE
TWEET

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

kolioi Sep 29th, 2017 24 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top