Write a program to use jagged arrays.
public
void jaggedarray()
{
Console.Write("Enter the value\n");
//int[,]
a = new int[2, 2]; int[,] b = new int[2, 2]; int[,] c = new int[2, 2];
int[][,]
Arr;
Arr = new int[3][,];
Arr[0] = new
int[2, 2];
Arr[1] = new int[2, 2];
Arr[2] = new int[2, 2];
for
(int i = 0; i < Arr.GetLength(0); i++)
{
for (int j = 0; j
< Arr[i].GetLength(0); j++)
{
for
(int k = 0; k < Arr[i].GetLength(1); k++)
{
Arr[i][j, k]
= Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine("\n");
}
for
(int i = 0; i < Arr.GetLength(0); i++)
{
Console.WriteLine("\n");
for (int j = 0; j
< Arr[i].GetLength(0); j++)
{
Console.WriteLine("\n");
for (int k = 0; k < Arr[i].GetLength(1); k++)
{
Console.Write("{0}\t",
Arr[i][j, k]);
}
}
Console.WriteLine("");
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment