Create a mixed array. Consider there are three tables, each with different numbers of rows and columns.
Table-1 6 rows, 2 columns
Table-2 4 rows, 8 columns
Table-2 5 rows, 4 columns
Assign values in only one mixed array and display values of all tables. class Program
{
static void Main(string[] args)
{
int[][,] mixedArray = new int[3][,]
{
new int[6,2]{{5,2},{6,4},{9,7},{9,3},{7,2},{6,1}},
new int[4,8]{{1,4,7,8,9,5,3,4},{7,8,1,2,3,4,6,8},{4,9,5,6,7,8,1,2},{9,6,7,4,5,8,6,4}},
new int[5,4]{{1,9,6,7},{4,3,9,7,},{2,1,9,4},{7,3,6,1},{8,2,1,4}}
};
Console.WriteLine("Enter the mixed array");
for (int i = 0; i < mixedArray.Length; i++)
{
for (int j = 0; j < i; j++)
mixedArray[i][j, i] = int.Parse(Console.ReadLine());
}
for (int i = 0; i < mixedArray.Length; i++)
{
for (int j = 0; j < i; j++)
{
Console.WriteLine(mixedArray[i][j, i]);
}
}
Console.WriteLine();
Console.ReadLine();
}
}
No comments:
Post a Comment