desito07

Cake

Sep 24th, 2023
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. namespace _1
  2. {
  3. internal class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. int width = int.Parse(Console.ReadLine());
  8. int height = int.Parse(Console.ReadLine());
  9. int count = width * height;
  10. string command = Console.ReadLine();
  11.  
  12. while (command != "STOP")
  13. {
  14. int piecesToTake = int.Parse(command);
  15.  
  16.  
  17. if (piecesToTake > count)
  18. {
  19. Console.WriteLine($"No more cake left! You need {piecesToTake - count} pieces more.");
  20. break;
  21. }
  22. count -= piecesToTake;
  23.  
  24. if (count <= 0)
  25. {
  26. break;
  27. }
  28. command = Console.ReadLine();
  29. }
  30. if (command == "STOP")
  31. {
  32. Console.WriteLine($"{count} pieces are left.");
  33. }
  34. }
  35. }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment