Create a program that will transpose the elements (values) of a 16-element two-
dimensional integer array (4x4) Transpose. The value of each element should be obtained
from the user (or inputs).
For example:
Original Entries Transposed Entries
1 2 3 4 1 5 9 3
5 6 7 8 2 6 0 4
9 0 1 2 3 7 1 5
3 4 5 6 4 8 2 6
using System;
namespace transp
{
class Program
{
static void Main()
{
int[,] transpose =
{
{1,2,3,4}, // From example
{5,6,7,8},
{9,0,1,2},
{3,4,5,6}
};
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
Console.Write("{0} ", transpose[i, j]);
}
for (int j = 0; j < 4; j++)
{
Console.Write("{0} ", transpose[j, i]);
}
Console.WriteLine();
Console.WriteLine();
}
Console.WriteLine();
Console.Write("Press any key to exit. . . ");
Console.ReadKey(true);
}
}
}
Comments
Leave a comment