Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int width = int.Parse(Console.ReadLine());
- int length = int.Parse(Console.ReadLine());
- int countPieces = width * length;
- //лице на тортата = брой на парчетата
- //стоп: команда = "STOP"
- //продължаваме: команда != "STOP"
- //команда => "STOP" или брой парчета ("4")
- string command = Console.ReadLine();
- while (command != "STOP")
- {
- //брой взети парчета -> command = "2"
- int takenPieces = int.Parse(command);
- //извадим от общия брой взетите парчета
- countPieces -= takenPieces;
- //проверка дали имам останали парчета
- if (countPieces <= 0)
- {
- Console.WriteLine($"No more cake left! You need {Math.Abs(countPieces)} pieces more.");
- break;
- }
- command = Console.ReadLine();
- }
- if (command == "STOP")
- {
- Console.WriteLine($"{countPieces} pieces are left.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment