Advertisement
kolioi

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

Sep 29th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Pool
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int V = int.Parse(Console.ReadLine()),
  10.                 P1 = int.Parse(Console.ReadLine()),
  11.                 P2 = int.Parse(Console.ReadLine());
  12.  
  13.             double H = double.Parse(Console.ReadLine());
  14.  
  15.             double V1 = P1 * H,
  16.                    V2 = P2 * H;
  17.  
  18.             if (V1 + V2 <= V)
  19.             {
  20.                 int x = (int)((V1 + V2) * 100.0 / V),
  21.                     y = (int)(V1 * 100.0 / (V1 + V2)),
  22.                     z = (int)(V2 * 100.0 / (V1 + V2));
  23.                 Console.WriteLine($"The pool is {x}% full. Pipe 1: {y}%. Pipe 2: {z}%.");
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine($"For {H} hours the pool overflows with {V1 + V2 - V:F1} liters.");
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement