Skip to content

Commit 40517d8

Browse files
authored
Merge pull request #920 from ManishSah26/patch-1
Create Second.java
2 parents 5563df8 + 86cbe3b commit 40517d8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Second.java

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class Second{
2+
public static int getSecondLargest(int[] a, int total){
3+
int temp;
4+
for (int i = 0; i < total; i++)
5+
{
6+
for (int j = i + 1; j < total; j++)
7+
{
8+
if (a[i] > a[j])
9+
{
10+
temp = a[i];
11+
a[i] = a[j];
12+
a[j] = temp;
13+
}
14+
}
15+
}
16+
return a[total-2];
17+
}
18+
public static void main(String args[]){
19+
int a[]={1,2,5,6,3,2};
20+
int b[]={44,66,99,77,33,22,55};
21+
System.out.println("Second Largest: "+getSecondLargest(a,6));
22+
System.out.println("Second Largest: "+getSecondLargest(b,7));
23+
}}

0 commit comments

Comments
 (0)