-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_IQTest.java
More file actions
40 lines (34 loc) · 854 Bytes
/
A_IQTest.java
File metadata and controls
40 lines (34 loc) · 854 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;
public class A_IQTest {
public static void main(String[] args) {
int count;
int num1;
int even = 0;
int odd = 0;
Scanner input = new Scanner(System.in);
while (true) {
count = input.nextInt();
if (count >= 3 && count <= 100) break;
}
int[] num = new int[count];
for (int i = 0; i < count; i++) {
while (true) {
num1 = input.nextInt();
if (num1 <= 100) break;
}
num[i] = num1;
if (num[i] % 2 == 0) even++;
if (num[i] % 2 != 0) odd++;
}
if (even == 1) {
for (int i = 0; i < count; i++) {
if (num[i] % 2 == 0) System.out.println(i + 1);
}
} else if (odd == 1) {
for (int i = 0; i < count; i++) {
if (num[i] % 2 != 0) System.out.println(i + 1);
}
}
input.close();
}
}