nassss

Untitled

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