Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Bomb_The_Basement
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int[] dimensions = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  11. int rows = dimensions[0];
  12. int cols = dimensions[1];
  13.  
  14. int[][] matrix = new int[rows][];
  15.  
  16. for (int row = 0; row < matrix.GetLength(0); row++)
  17. {
  18. matrix[row] = new int[cols];
  19. }
  20.  
  21. int[] bomb = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  22.  
  23. int bombRow = bomb[0];
  24. int bombCol = bomb[1];
  25. int bombRadius = bomb[2];
  26.  
  27. for (int row = 0; row < rows; row++)
  28. {
  29. for (int col = 0; col <cols; col++)
  30. {
  31. double distance = Math.Sqrt(Math.Pow(row - bombRow, 2) + Math.Pow(col - bombCol, 2));
  32.  
  33. if (distance <= bombRadius)
  34. {
  35. matrix[row][col] = 1;
  36. }
  37. }
  38. }
  39. int[][] secondMatrix = new int[cols][];
  40.  
  41. for (int row = 0; row < cols; row++)
  42. {
  43. secondMatrix[row] = new int[rows];
  44. for (int col = 0; col < rows; col++)
  45. {
  46. secondMatrix[row][col] = matrix[col][row];
  47. }
  48. secondMatrix[row] = secondMatrix[row].OrderByDescending(x => x).ToArray();
  49. }
  50.  
  51. for (int row = 0; row < rows; row++)
  52. {
  53. for (int col = 0; col < cols; col++)
  54. {
  55. matrix[row][col] = secondMatrix[col][row];
  56. }
  57. }
  58.  
  59. Console.WriteLine(String.Join(Environment.NewLine,matrix.Select(r => string.Join("",r))));
  60.  
  61.  
  62. }
  63.  
  64.  
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement