Advertisement
social1986

Untitled

Dec 12th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MATRIX
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int[][] matrix =
  10. {
  11. new int[] {1, 2, 4, 7 },
  12. new int[] {3, 5, 8, 10 },
  13. new int[] {6, 9 , 11, 12 }
  14. };
  15.  
  16. var temp = -1;
  17.  
  18. for (int i = 0; i < matrix[0].Length; i++)
  19. {
  20. var row = 0;
  21. temp++;
  22. var col = temp;
  23.  
  24. while (true)
  25. {
  26. if (row == 0 && col == 0)
  27. {
  28. Console.WriteLine(matrix[row][col]);
  29. break;
  30. }
  31. Console.WriteLine(matrix[row][col]);
  32.  
  33. col--;
  34. row++;
  35.  
  36. if (row == matrix.Length || col < 0)
  37. {
  38. break;
  39. }
  40. }
  41. }
  42.  
  43. var colum = matrix[1].Length - 1;
  44. temp = 1;
  45. var rows = 1;
  46.  
  47. for (int i = 1; i <= matrix.Length; i++)
  48. {
  49. Console.WriteLine(matrix[rows][colum]);
  50. colum--;
  51. if (rows == matrix.Length - 1)
  52. {
  53. rows = temp;
  54. temp++;
  55. colum = matrix[1].Length - 1;
  56. }
  57. rows++;
  58. }
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement