using System;
namespace Console_MatrixTranspose
{
class MatrixTranspose
{
public void mT()
{
//Declaring the array to accept input from users
int i,j;
Console.WriteLine("Enter the rows :");
int m = int.Parse(Console.ReadLine());
Console.WriteLine("Enter the columns :");
int n = int.Parse(Console.ReadLine());
int[,] a = new int[m, n];
int[,] tp = new int[m, n];
//Input Matrix element
Console.WriteLine("Enter the elements :");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
a[i, j] = int.Parse(Console.ReadLine());
}
}
//Transpose operation performing
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
tp[i, j] = a[j, i];
}
}
//For Print the Transpose Matirx
Console.WriteLine("Print the Transpose Matrix :");
for (i = 0; i < m; i++)
{
Console.WriteLine("");
for (j = 0; j < n; j++)
{
Console.Write(tp[i, j]);
Console.Write("\t");
}
}
}
static void Main(string[] args)
{
MatrixTranspose mt = new MatrixTranspose();
mt.mT();
Console.ReadKey();
}
}
}
No comments:
Post a Comment