Advertisement
NadyaMisheva

mina

Mar 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Program
  6. {
  7. public static void Main()
  8. {
  9. string[] dim = Console.ReadLine().Split(',');
  10. int row = int.Parse(dim[0]);
  11. int col = int.Parse(dim[1]);
  12. int[,] battlefield = new int[row, col];
  13.  
  14. for(int i = 0; i < row; i++)
  15. {
  16. for (int j = 0; j < col; j++)
  17. {
  18. battlefield[i, j] = 100;
  19. }
  20. }
  21. while (true)
  22. {
  23. string[] command = Console.ReadLine().Split(',');
  24. if (command[0] == "GAME OVER")
  25. {
  26. break;
  27. }
  28. int x = int.Parse(command[0]);
  29. int y = int.Parse(command[1]);
  30. int damage = int.Parse(command[2]);
  31.  
  32. if (x < row && x >= 0 && y < col && y >= 0)
  33. {
  34. battlefield[x, y] -= damage;
  35. if (battlefield[x, y] < 0)
  36. {
  37. battlefield[x, y] = 0;
  38. }
  39. }
  40. }
  41. for ( int i = 0; i < row; i ++)
  42. {
  43. for (int j = 0; j < col; j++)
  44. {
  45. Console.Write(battlefield[i, j] + " ");
  46. }
  47. Console.WriteLine();
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement