Advertisement
StoimenK

2.7.Water_Overflow

Jan 26th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _2._7.Water_Overflow
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int firstIn = int.Parse(Console.ReadLine());
  14.  
  15.             int capacity = 255;
  16.             int total = 0;
  17.  
  18.             for(int i = 0; i < firstIn; i++)
  19.             {
  20.                 int secondIn = int.Parse(Console.ReadLine());
  21.                 total += secondIn;
  22.  
  23.                 if (total > capacity)
  24.                 {
  25.                     Console.WriteLine("Insufficient capacity!");
  26.                     total -= secondIn;
  27.                 }
  28.             }
  29.             Console.WriteLine(total);
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement