Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Cake
- {
- class Program
- {
- static void Main(string[] args)
- {
- int width = int.Parse(Console.ReadLine());
- int length = int.Parse(Console.ReadLine());
- int cake = width * length;
- while (cake > 0)
- {
- string command = Console.ReadLine();
- if (command =="STOP")
- {
- Console.WriteLine($"{cake} pieces are left.");
- break;
- }
- else
- {
- cake -= int.Parse(command);
- }
- }
- if (cake <= 0)
- {
- cake = Math.Abs(cake);
- Console.WriteLine($"No more cake left! You need {cake} pieces more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement