-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPares.java
38 lines (29 loc) · 959 Bytes
/
Pares.java
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
import java.util.Scanner;
public class Pares {
public static void main(String[] args) {
try (Scanner ler = new Scanner(System.in)) {
final int SIZE = 10;
int[] a;
a = new int[SIZE];
for (int i = 0; i < SIZE; i++) {
System.out.println("Insira o valor " + (i + 1) + ":");
a[i] = ler.nextInt();
}
for (int i = 0; i < SIZE; i++) {
if (i == 0) {
System.out.print("Vetor A = [" + a[i] + ", ");
} else if (i == (SIZE - 1)) {
System.out.println(a[i] + "]");
} else {
System.out.print(a[i] + ", ");
}
}
System.out.println("Valores pares do vetor A:");
for (int i = 0; i < SIZE; i++) {
if (a[i] % 2 == 0) {
System.out.print(a[i] + " | ");
}
}
}
}
}