Advertisement
Alexander_B

Cake

Feb 10th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DomashnoCake
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int cakeHight = int.Parse(Console.ReadLine());
  14. int cakeLenght = int.Parse(Console.ReadLine());
  15.  
  16. int numberPieces = cakeHight * cakeLenght;
  17.  
  18. while (true)
  19. {
  20. if (numberPieces < 0)
  21. {
  22. break;
  23. }
  24. else
  25. {
  26. string command = Console.ReadLine();
  27.  
  28. if (command == "STOP")
  29. {
  30. break;
  31. }
  32. else
  33. {
  34. int piecesTaken = int.Parse(command);
  35.  
  36. numberPieces -= piecesTaken;
  37.  
  38. }
  39. }
  40. }
  41.  
  42. if (numberPieces > 0)
  43. {
  44. Console.WriteLine($"{numberPieces} pieces are left.");
  45. }
  46. else
  47. {
  48. int piecesNeeded = Math.Abs(numberPieces);
  49.  
  50. Console.WriteLine($"No more cake left! You need {piecesNeeded} pieces more.");
  51. }
  52.  
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement