Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2017
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 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 _04.Cake
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int width = int.Parse(Console.ReadLine());
  15.             int length = int.Parse(Console.ReadLine());
  16.             int pieces = width * length;
  17.             string input;
  18.             while ((input = Console.ReadLine()) != "STOP")
  19.             {
  20.                 int piecesToTake = int.Parse(input);
  21.                 if (piecesToTake > pieces)
  22.                 {
  23.                     Console.WriteLine($"No more cake left! You need {piecesToTake - pieces} pieces more.");
  24.                     return;
  25.                 }
  26.                 pieces -= piecesToTake;
  27.             }
  28.             Console.WriteLine($"{pieces} pieces are left.");
  29.  
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement