Krasimir_Slavov

Untitled

Feb 5th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Ex_Water_Overflow
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int liters = int.Parse(Console.ReadLine());
  11.  
  12.             int capacity = 255;
  13.             int sumLiters = 0;
  14.  
  15.             for (int i = 0; i <= n; i++)
  16.             {
  17.  
  18.                 if (capacity >= sumLiters)
  19.                 {
  20.                     Console.WriteLine("Insufficient capacity!");
  21.                     Console.WriteLine($"{sumLiters}");
  22.                 }
  23.                 sumLiters += liters;
  24.                 n--;
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment