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