Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int length = int.Parse(Console.ReadLine());
- int width = int.Parse(Console.ReadLine());
- int cake = length * width;
- string input;
- bool cakeleft=true;
- while ((input=Console.ReadLine())!= "Stop" && cakeleft)
- {
- int pieces = int.Parse(input);
- cake -= pieces;
- cakeleft = cake - pieces > 0;
- }
- if (input == "Stop")
- {
- Console.WriteLine("{0} pieces are left.",cake);
- }
- else
- {
- Console.WriteLine("No more cake left.You need {0} piece more.",Math.Abs(cake));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment