Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Cake
- {
- class Program
- {
- static void Main(string[] args)
- {
- int widthPieceCake = int.Parse(Console.ReadLine());
- int lenghtPieceCake = int.Parse(Console.ReadLine());
- int piecesCakeTaken = 0;
- int singleTakenPieces = 0;
- int wholeCake = widthPieceCake * lenghtPieceCake;
- string command = "";
- while (wholeCake >= piecesCakeTaken)
- {
- command = Console.ReadLine();
- if (command == "STOP")
- {
- int piecesLeft = wholeCake - piecesCakeTaken;
- Console.WriteLine($"{piecesLeft} pieces are left.");
- return;
- }
- singleTakenPieces = int.Parse(command);
- piecesCakeTaken += singleTakenPieces;
- }
- int leftPieces = piecesCakeTaken - wholeCake;
- Console.WriteLine($"No more cake left! You need {leftPieces} pieces more.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement