Guest User

Untitled

a guest
Oct 18th, 2021
49
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace TheBattleOfTheFiveArmies
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int underArmour = int.Parse(Console.ReadLine());
  10. int rowsMap = int.Parse(Console.ReadLine());
  11.  
  12. char[][] warMap = new char[rowsMap][];
  13.  
  14. int armyRow = 0;
  15. int armyCol = 0;
  16.  
  17.  
  18. for (int row = 0; row < rowsMap; row++)
  19. {
  20. char[] statusLooksRows = Console.ReadLine().ToCharArray();
  21.  
  22. warMap[row] = statusLooksRows;
  23.  
  24. }
  25.  
  26. for (int row = 0; row < rowsMap; row++)
  27. {
  28. for (int col = 0; col < warMap[row].Length; col++)
  29. {
  30. if (warMap[row][col] == 'A')
  31. {
  32. armyRow = row;
  33. armyCol = col;
  34. }
  35. }
  36. }
  37.  
  38. while (true)
  39. {
  40. string[] command = Console.ReadLine().Split();
  41.  
  42. string move = command[0];
  43. int spawnRow = int.Parse(command[1]);
  44. int spawnCol = int.Parse(command[2]);
  45.  
  46. warMap[spawnRow][spawnCol] = 'O';
  47.  
  48. if (move == "up" && armyRow - 1 >= 0)
  49. {
  50. warMap[armyRow][armyCol] = '-';
  51. armyRow--;
  52.  
  53. }
  54. else if (move == "right" && armyCol + 1 < warMap[armyRow].Length)
  55. {
  56. warMap[armyRow][armyCol] = '-';
  57. armyCol++;
  58. }
  59. else if (move == "left" && armyCol - 1 >= 0)
  60. {
  61. warMap[armyRow][armyCol] = '-';
  62. armyCol--;
  63. }
  64. else if (move == "down" && armyRow + 1 < rowsMap)
  65. {
  66. warMap[armyRow][armyCol] = '-';
  67. armyRow++;
  68. }
  69.  
  70. underArmour--;
  71.  
  72.  
  73. if (warMap[armyRow][armyCol] == 'O')
  74. {
  75. underArmour -= 2;
  76.  
  77. if (underArmour <= 0)
  78. {
  79. warMap[armyRow][armyCol] = 'X';
  80. Console.WriteLine($"The army was defeated at {armyRow};{armyCol}.");
  81. break;
  82. }
  83. }
  84.  
  85. else if (warMap[armyRow][armyCol] == 'M')
  86. {
  87. warMap[armyRow][armyCol] = '-';
  88. Console.WriteLine($"The army managed to free the Middle World! Armor left: {underArmour}");
  89. break;
  90. }
  91. warMap[armyRow][armyCol] = 'A';
  92. }
  93.  
  94. for (int i = 0; i < rowsMap; i++)
  95. {
  96. Console.WriteLine(String.Join("", warMap[i]));
  97. }
  98. }
  99. }
  100. }
  101.  
RAW Paste Data