We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 51be242 commit a1e58b4Copy full SHA for a1e58b4
problem16.java
@@ -0,0 +1,45 @@
1
+/**
2
+Solved by
3
+Chandhiny, IT dept.
4
+*/
5
+
6
+import java.util.Arrays;
7
+import java.util.Scanner;
8
9
+public class second_largest
10
+{
11
12
+ public static void main(String[] args)
13
+ {
14
+ Scanner s=new Scanner(System.in);
15
+ int n=s.nextInt();
16
+ int a=s.nextInt();
17
+ int b=s.nextInt();
18
+ int first,second;
19
+ if(a>b)
20
21
+ first=a;second=b;
22
+ }
23
+ else
24
25
+ first=b;
26
+ second=a;
27
28
+ for(int i=2;i<n;i++)
29
30
+ a=s.nextInt();
31
+ if(a<first && a>second)
32
33
+ else if(a>first)
34
35
+ second=first;
36
+ first=a;
37
38
39
40
41
+ System.out.println(second);
42
43
44
45
+}
0 commit comments