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