nassss

Untitled

Jan 8th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. namespace MultidimensionArrays
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. //int n = int.Parse(Console.ReadLine());
  11. int[,] matrix = new int[3, 3]
  12. {
  13. {1, 2, 3, },
  14. {4, 5, 6, },
  15. {7, 8, 9, },
  16. };
  17. //int[,] matrix = new int[n, n];
  18.  
  19. //for (int i = 0; i < matrix.GetLength(0); i++)
  20. //{
  21. // for (int j = 0; j < matrix.GetLength(1); j++)
  22. // {
  23. // matrix[i, j] = int.Parse(Console.ReadLine());
  24. // }
  25. //}
  26. int rows = 0;
  27.  
  28. int counter = 0;
  29.  
  30. for (int row = matrix.GetLength(0) - 1; row >= 0; row--)
  31. {
  32. rows = row;
  33. for (int col = 0; col <= counter; col++)
  34. {
  35.  
  36. Console.Write(matrix[rows, col] + " ");
  37. rows++;
  38. }
  39. Console.WriteLine();
  40. counter++;
  41. }
  42.  
  43. int cols = 1;
  44.  
  45. for (int i = matrix.GetLength(0) - 2; i >= 0; i--)
  46. {
  47. for (int row = 0; row <= i; row++)
  48. {
  49. Console.Write(matrix[row, cols] + " ");
  50. cols++;
  51. }
  52. Console.WriteLine();
  53. cols--;
  54. }
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment