forked from akshika898/HACKTOBER_FEST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray_SecMax.c
More file actions
40 lines (40 loc) · 803 Bytes
/
Array_SecMax.c
File metadata and controls
40 lines (40 loc) · 803 Bytes
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
import java.util.Scanner;
// Other imports go here
// Do NOT change the class name
class Main{
public static void main(String[] args)
{
int a[] = new int[5];
Scanner sc = new Scanner(System.in);
for(int i=0;i<5;i++)
{
a[i]=sc.nextInt();
}
int large =-32768 ,index=0,c=0;
for(int i=0;i<5;i++)
{
if(a[i]>large)
{
large = a[i];
index = i;
}
if(a[i]==0)
c++;
}
int seclarge= -32768;
for(int i=0;i<5;i++)
{
if(a[i]!=large&&i!=index)
{
if(a[i]>seclarge)
{
seclarge = a[i];
}
}
}
if(c!=5)
System.out.print(seclarge);
else
System.out.println(0);
}
}