Advertisement
silvana1303

water overflow

Jun 19th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Diagnostics.CodeAnalysis;
  5. using System.Linq;
  6. using System.Threading;
  7.  
  8. namespace ConsoleApp1
  9. {
  10.     class Exam
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.  
  15.             int times = int.Parse(Console.ReadLine());
  16.             int capacity = 0;
  17.  
  18.             for (int i = 0; i < times; i++)
  19.             {
  20.                 int litres = int.Parse(Console.ReadLine());
  21.  
  22.                 if (capacity + litres > 255)
  23.                 {
  24.                     Console.WriteLine("Insufficient capacity!");
  25.                 }
  26.                 else
  27.                 {
  28.                     capacity += litres;
  29.                 }
  30.             }
  31.  
  32.             Console.WriteLine(capacity);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement