You are on page 1of 2

C:\Users\admin\Documents\Microsft Vs code\ConsoleApp5\ConsoleApp5\Program.

cs 1
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6
7 namespace ConsoleApp5
8 {
9 internal class Program
10 {
11 static void Main(string[] args)
12 {
13 // Declare and initialize the input matrix
14 int[,] input = { { 1, 2, 3 },
15
16 { 4, 5, 6 },
17
18 { 7, 8, 9 } };
19
20 // Create an empty output matrix
21 int[,] output = new int[3, 3];
22
23 // Loop through rows of input matrix
24 for (int n = 0; n < 3; n++)
25 {
26 // Loop through columns of input matrix
27 for (int m = 0; m < 3; m++)
28 {
29 output[n, m] = input[m, n]; // Assign elements from input to output matrix
30 Console.Write(" "+ output[n, m] + " |");// Display the assign element
31 }
32 Console.WriteLine();// Move to the next line after transposing a row
33
34 }
35 Console.ReadKey();
C:\Users\admin\Documents\Microsft Vs code\ConsoleApp5\ConsoleApp5\Program.cs 2
36 }
37 }
38 }
39

You might also like