Threed90

Хистограма/Histogram

Dec 20th, 2019
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int volume, p1, p2;
  7.     float hours;
  8.  
  9.     scanf_s("%d", &volume);
  10.     scanf_s("%d", &p1);
  11.     scanf_s("%d", &p2);
  12.     scanf_s("%f", &hours);
  13.  
  14.     float pipe1 = p1 * hours;
  15.     float pipe2 = p2 * hours;
  16.  
  17.     float total = pipe1 + pipe2;
  18.  
  19.     if (volume < total)
  20.     {
  21.         printf_s("For %f hours the pool overflows with %.1f liters.", hours, (total - volume));
  22.     }
  23.     else
  24.     {
  25.         int volumePercent = (total / volume) * 100;
  26.         int p1Percent = (pipe1 / total) * 100;
  27.         int p2Percent = (pipe2 / total) * 100;
  28.         printf_s("The pool is %d%% full. Pipe 1: %d%%. Pipe 2: %d%%.", volumePercent, p1Percent, p2Percent);
  29.     }
  30.  
  31.     system("pause");
  32.     return 0;
  33. }
RAW Paste Data