bacco

Торта

Mar 5th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics.Tracing;
  3.  
  4. namespace КоледнаШапка
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             var w = int.Parse(Console.ReadLine());
  11.             var l = int.Parse(Console.ReadLine());
  12.  
  13.             var pieces = w * l;
  14.             var piecesCount = 0;
  15.  
  16.             for (int i = 1; i <= 1000; i++)
  17.             {
  18.                 try
  19.                 {
  20.                     var piecesEat = int.Parse(Console.ReadLine());
  21.  
  22.                     piecesCount = piecesCount + piecesEat;
  23.                 }
  24.                 catch
  25.                 {
  26.                     break;
  27.                 }
  28.             }
  29.             var diff = pieces - piecesCount;
  30.  
  31.             if (diff >= 0)
  32.             {
  33.                 Console.WriteLine($"{diff} pieces are left.");
  34.             }
  35.             else
  36.             {
  37.                 diff = Math.Abs(diff);
  38.                 Console.WriteLine($"No more cake left! You need {diff} pieces more.");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment