Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MATRIX
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[][] matrix =
- {
- new int[] {1, 2, 4, 7 },
- new int[] {3, 5, 8, 10 },
- new int[] {6, 9 , 11, 12 }
- };
- var temp = -1;
- for (int i = 0; i < matrix[0].Length; i++)
- {
- var row = 0;
- temp++;
- var col = temp;
- while (true)
- {
- if (row == 0 && col == 0)
- {
- Console.WriteLine(matrix[row][col]);
- break;
- }
- Console.WriteLine(matrix[row][col]);
- col--;
- row++;
- if (row == matrix.Length || col < 0)
- {
- break;
- }
- }
- }
- var colum = matrix[1].Length - 1;
- temp = 1;
- var rows = 1;
- for (int i = 1; i <= matrix.Length; i++)
- {
- Console.WriteLine(matrix[rows][colum]);
- colum--;
- if (rows == matrix.Length - 1)
- {
- rows = temp;
- temp++;
- colum = matrix[1].Length - 1;
- }
- rows++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement