bullit3189

Helen's Abduction

May 27th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.92 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5.  
  6. public class Program
  7. {
  8. public static void Main()
  9. {
  10. int energy = int.Parse(Console.ReadLine());
  11. int rows = int.Parse(Console.ReadLine());
  12.  
  13. char[][] jagged = new char[rows][];
  14.  
  15. int parisRow = 0;
  16. int parisCol = 0;
  17.  
  18. for(int row=0; row<rows; row++)
  19. {
  20. string input = Console.ReadLine();
  21. jagged[row] = new char[input.Length];
  22.  
  23. for(int col=0; col<jagged[row].Length; col++)
  24. {
  25. jagged[row][col] = input[col];
  26.  
  27. if(jagged[row][col]=='P')
  28. {
  29. parisRow = row;
  30. parisCol = col;
  31. }
  32. }
  33. }
  34.  
  35. while(true)
  36. {
  37. string[] command = Console.ReadLine().Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries);
  38.  
  39. string move = command[0];
  40. int spartanRow = int.Parse(command[1]);
  41. int spartanCol = int.Parse(command[2]);
  42.  
  43. jagged[spartanRow][spartanCol]='S';
  44.  
  45. if(move=="up")
  46. {
  47. if(parisRow-1>=0)
  48. {
  49. jagged[parisRow][parisCol]='-';
  50. energy-=1;
  51. parisRow-=1;
  52.  
  53. if(jagged[parisRow][parisCol]=='S')
  54. {
  55. energy-=2;
  56.  
  57. if(energy<=0)
  58. {
  59. jagged[parisRow][parisCol]='X';
  60. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  61. break;
  62. }
  63. }
  64. else if (jagged[parisRow][parisCol]=='H')
  65. {
  66. jagged[parisRow][parisCol]='-';
  67. Console.WriteLine("Paris has successfully abducted Helen! Energy left: {0}",energy);
  68. break;
  69. }
  70.  
  71. if(energy<=0)
  72. {
  73. jagged[parisRow][parisCol]='X';
  74. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  75. break;
  76. }
  77. }
  78. else
  79. {
  80. energy-=1;
  81.  
  82. if(energy<=0)
  83. {
  84. jagged[parisRow][parisCol]='X';
  85. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  86. break;
  87. }
  88. }
  89. }
  90. else if (move=="down")
  91. {
  92. if(parisRow+1<rows)
  93. {
  94. jagged[parisRow][parisCol]='-';
  95. energy-=1;
  96. parisRow+=1;
  97.  
  98. if(jagged[parisRow][parisCol]=='S')
  99. {
  100. energy-=2;
  101.  
  102. if(energy<=0)
  103. {
  104. jagged[parisRow][parisCol]='X';
  105. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  106. break;
  107. }
  108. }
  109. else if (jagged[parisRow][parisCol]=='H')
  110. {
  111. jagged[parisRow][parisCol]='-';
  112. Console.WriteLine("Paris has successfully abducted Helen! Energy left: {0}",energy);
  113. break;
  114. }
  115.  
  116. if(energy<=0)
  117. {
  118. jagged[parisRow][parisCol]='X';
  119. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  120. break;
  121. }
  122. }
  123. else
  124. {
  125. energy-=1;
  126.  
  127. if(energy<=0)
  128. {
  129. jagged[parisRow][parisCol]='X';
  130. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  131. break;
  132. }
  133. }
  134. }
  135. else if(move=="left")
  136. {
  137. if(parisCol-1>=0)
  138. {
  139. jagged[parisRow][parisCol]='-';
  140. energy-=1;
  141. parisCol-=1;
  142.  
  143. if(jagged[parisRow][parisCol]=='S')
  144. {
  145. energy-=2;
  146.  
  147. if(energy<=0)
  148. {
  149. jagged[parisRow][parisCol]='X';
  150. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  151. break;
  152. }
  153. }
  154. else if (jagged[parisRow][parisCol]=='H')
  155. {
  156. jagged[parisRow][parisCol]='-';
  157. Console.WriteLine("Paris has successfully abducted Helen! Energy left: {0}",energy);
  158. break;
  159. }
  160.  
  161. if(energy<=0)
  162. {
  163. jagged[parisRow][parisCol]='X';
  164. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  165. break;
  166. }
  167. }
  168. else
  169. {
  170. energy-=1;
  171.  
  172. if(energy<=0)
  173. {
  174. jagged[parisRow][parisCol]='X';
  175. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  176. break;
  177. }
  178. }
  179. }
  180. else if (move == "right")
  181. {
  182. if(parisCol+1<jagged[parisRow].Length)
  183. {
  184. jagged[parisRow][parisCol]='-';
  185. energy-=1;
  186. parisCol+=1;
  187.  
  188. if(jagged[parisRow][parisCol]=='S')
  189. {
  190. energy-=2;
  191.  
  192. if(energy<=0)
  193. {
  194. jagged[parisRow][parisCol]='X';
  195. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  196. break;
  197. }
  198. }
  199. else if (jagged[parisRow][parisCol]=='H')
  200. {
  201. jagged[parisRow][parisCol]='-';
  202. Console.WriteLine("Paris has successfully abducted Helen! Energy left: {0}",energy);
  203. break;
  204. }
  205.  
  206. if(energy<=0)
  207. {
  208. jagged[parisRow][parisCol]='X';
  209. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  210. break;
  211. }
  212. }
  213. else
  214. {
  215. energy-=1;
  216.  
  217. if(energy<=0)
  218. {
  219. jagged[parisRow][parisCol]='X';
  220. Console.WriteLine("Paris died at {0};{1}.",parisRow,parisCol);
  221. break;
  222. }
  223. }
  224. }
  225. }
  226.  
  227. foreach (var row in jagged)
  228. {
  229. Console.WriteLine(row);
  230. }
  231. }
  232. }
Advertisement
Add Comment
Please, Sign In to add comment