Advertisement
bokoto83

Cake

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