Write a program of Transpose matrix
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the dimesion of the array");
int n = int.Parse(Console.ReadLine());
int[,] arr=new int[n,n];
Console.WriteLine("your matrix format is:{0}", n * n);
Console.WriteLine("Please Enter the array element");
for(int i=0;i<n; i++)
{
for(int j=0;j<n;j++)
{
arr[i,j]=int.Parse(Console.ReadLine());
}
}
Console.WriteLine("Your matrix representation is: ");
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
Console.Write(arr[i,j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("Your transpose matrix is:");
for (int i = 0; i <= n-1;i++ )
{
for(int j=0;j<=n-1;j++ )
{
Console.Write(arr[j, i] + " ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
Output:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the dimesion of the array");
int n = int.Parse(Console.ReadLine());
int[,] arr=new int[n,n];
Console.WriteLine("your matrix format is:{0}", n * n);
Console.WriteLine("Please Enter the array element");
for(int i=0;i<n; i++)
{
for(int j=0;j<n;j++)
{
arr[i,j]=int.Parse(Console.ReadLine());
}
}
Console.WriteLine("Your matrix representation is: ");
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
Console.Write(arr[i,j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("Your transpose matrix is:");
for (int i = 0; i <= n-1;i++ )
{
for(int j=0;j<=n-1;j++ )
{
Console.Write(arr[j, i] + " ");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
Output:
No comments:
Post a Comment