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