-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMinMax26.java
More file actions
33 lines (28 loc) · 695 Bytes
/
MinMax26.java
File metadata and controls
33 lines (28 loc) · 695 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
package minmax;
import java.util.Scanner;
public class MinMax26 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n;
int r;
int num = 0;
int maxnum = 0;
System.out.println("n:");
n = scanner.nextInt();
for (int i = 1; i <= n; i++) {
r = scanner.nextInt();
if (r % 2 == 0) {
++num;
} else {
if (num > maxnum) {
maxnum = num;
}
num = 0;
}
}
if (num > maxnum) {
maxnum = num;
}
System.out.println(maxnum);
}
}