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