-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaxTwoArray.cs
52 lines (50 loc) · 1.27 KB
/
MaxTwoArray.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
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SkillMineProject7
{
class MaxTwoArray
{
static void maxelement(int no, int[][] arr)
{
int i = 0;
int max = 0;
int[] result = new int[no];
while (i < no)
{
for (int j = 0; j < arr[i].Length; j++)
{
if (arr[i][j] > max)
{
max = arr[i][j];
}
}
result[i] = max;
max = 0;
i++;
}
printArray(result);
}
private static void printArray(int[] result)
{
for (int i = 0; i < result.Length; i++)
{
Console.WriteLine(result[i]);
}
}
public static void Main(string[] args)
{
int[][] arr = new int[][]
{
new int[] {1, 2, 3},
new int[] {4, 5, 6},
new int[] {7, 8, 9},
new int[] {21, 11, 14}
};
maxelement(4, arr);
Console.WriteLine();
}
}
}