-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax24.java
More file actions
32 lines (25 loc) · 628 Bytes
/
MinMax24.java
File metadata and controls
32 lines (25 loc) · 628 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
package minmax;
import java.util.Scanner;
public class MinMax24 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n;
int r1 = 0;
int r2 = 0;
int maxsum = 0;
n = scanner.nextInt();
for (int i = 1; i <= n; i++) {
r2 = r1;
System.out.print(i + ".");
r1 = scanner.nextInt();
if (i == 2) {
maxsum = r2 + r1;
}
if (r1 + r2 > maxsum) {
maxsum = r2 + r1;
}
}
System.out.println(maxsum);
//
}
}