Advertisement
MARINA_GREBENAROVA

Cake

Oct 15th, 2021
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Cake
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int length = int.Parse(Console.ReadLine());
  10.             int width = int.Parse(Console.ReadLine());
  11.  
  12.             int cakePeaces = length * width;
  13.  
  14.             while (cakePeaces > 0)
  15.             {
  16.                 string input = Console.ReadLine();
  17.                 if (input == "STOP")
  18.                 {
  19.                     break;
  20.                 }
  21.                 int peaceOfCake = int.Parse(input);
  22.                 cakePeaces -= peaceOfCake;
  23.  
  24.             }
  25.             if (cakePeaces >= 0)
  26.             {
  27.                 Console.WriteLine($"{cakePeaces} pieces are left.");
  28.             }
  29.             else
  30.             {
  31.                 Console.WriteLine($"No more cake left! You need {Math.Abs(cakePeaces)} pieces more.");
  32.             }
  33.  
  34.         }
  35.     }
  36. }
  37.  
  38.  
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement