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 DomashnoCake
- {
- class Program
- {
- static void Main(string[] args)
- {
- int cakeHight = int.Parse(Console.ReadLine());
- int cakeLenght = int.Parse(Console.ReadLine());
- int numberPieces = cakeHight * cakeLenght;
- while (true)
- {
- if (numberPieces < 0)
- {
- break;
- }
- else
- {
- string command = Console.ReadLine();
- if (command == "STOP")
- {
- break;
- }
- else
- {
- int piecesTaken = int.Parse(command);
- numberPieces -= piecesTaken;
- }
- }
- }
- if (numberPieces > 0)
- {
- Console.WriteLine($"{numberPieces} pieces are left.");
- }
- else
- {
- int piecesNeeded = Math.Abs(numberPieces);
- Console.WriteLine($"No more cake left! You need {piecesNeeded} pieces more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement