Advertisement
Guest User

Untitled

a guest
May 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 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[] rowsAndCols = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  11. int rows = rowsAndCols[0];
  12. int cols = rowsAndCols[1];
  13. int[] bombs = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  14. int bombRow = bombs[0];
  15. int bombCol = bombs[1];
  16. int bombRange = bombs[2];
  17. int[,] arr = new int[rows, cols];
  18.  
  19. for (int row=0;row<rows;row++)
  20. {
  21. for(int col=0;col<cols;col++)
  22. {
  23. double distance = Math.Sqrt(Math.Pow(row - bombRow, 2) + Math.Pow(col - bombCol, 2));
  24.  
  25. if(distance<=bombRange)
  26. {
  27. arr[row, col] = 1;
  28. }
  29.  
  30. }
  31.  
  32. }
  33. int[][] secondArr = new int[cols][];
  34.  
  35. for(int row=0;row<cols;row++)
  36. {
  37. secondArr[row] = new int[rows];
  38. for(int col=0;col<rows;col++)
  39. {
  40. secondArr[row][col] = arr[col,row];
  41. }
  42. secondArr[row]= secondArr[row].OrderByDescending(x => x).ToArray();
  43. }
  44.  
  45. for(int row=0;row<rows;row++)
  46. {
  47. for (int col = 0; col<cols;col++)
  48. {
  49. arr[row, col] = secondArr[col][row];
  50. Console.Write(arr[row,col]);
  51. }
  52. Console.WriteLine();
  53. }
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement