Advertisement
DidiMilikina

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

Sep 30th, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include<iomanip>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     long volume_in_liters;
  10.     long debit_first_pipe;
  11.     long debit_second_pipe;
  12.     float hours;
  13.  
  14.     cin >> volume_in_liters >> debit_first_pipe >> debit_second_pipe >> hours;
  15.  
  16.     long percent = ((debit_first_pipe * hours + debit_second_pipe * hours) / volume_in_liters) * 100;
  17.     long percents_first_pipe = ((debit_first_pipe * hours) / (debit_first_pipe * hours + debit_second_pipe * hours)) * 100;
  18.     long percents_second_pipe = ((debit_second_pipe * hours) / (debit_first_pipe * hours + debit_second_pipe * hours)) * 100;
  19.     double capacity = debit_first_pipe * hours + debit_second_pipe * hours;
  20.  
  21.     if (capacity <= volume_in_liters)
  22.     {
  23.         cout << "The pool is " << percent << "% " << "full. " << "Pipe 1:" << " " << percents_first_pipe << "%." << " " << "Pipe 2:" << " " << percents_second_pipe << "%." << endl;
  24.     }
  25.     else if (capacity > volume_in_liters)
  26.     {
  27.         cout << "For " << hours << " " << "hours the pool overflows with " << fixed << setprecision(1) << capacity - volume_in_liters << " " << "liters." << endl;
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement