-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path05 ● Jagged Array.cs
40 lines (38 loc) · 1.28 KB
/
05 ● Jagged Array.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
namespace Jagged_Array
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the number of rows ");
int rows = int.Parse(Console.ReadLine());
int[][] Arr = new int[rows][];
for(int i = 0; i < rows; i++)
{
Console.WriteLine("Enter the number of elements in the {0}th row " , i);
int h = int.Parse(Console.ReadLine());
Arr[i] = new int[h];
}
for(int i = 0; i < Arr.Length; i++)//Read input
{
for(int j = 0; j < Arr[i].Length ;j++)
{
Console.Write("Row [{0}] : ", i);
Console.WriteLine("Enter {0},{1} Element " , i , j);
Arr[i][j] = int.Parse(Console.ReadLine());
}
}
Console.WriteLine("\n================================\n");
for(int i = 0; i < Arr.Length; i++)//Output
{
Console.Write("Row [{0}] : ",i);
for(int j = 0; j < Arr[i].Length ;j++)
{
Console.Write(Arr[i][j]+ " ");
}
Console.WriteLine();
}
}
}
}