-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex013.java
More file actions
27 lines (21 loc) · 768 Bytes
/
Copy pathex013.java
File metadata and controls
27 lines (21 loc) · 768 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
package listaexercicios02;
import java.util.Scanner;
public class ex013 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] vetor = new int[10];
StringBuilder contPar = new StringBuilder();
StringBuilder contImpar = new StringBuilder();
for(int i=0; i<vetor.length; i++) {
System.out.printf("Digite o %dº número: ", i+1);
vetor[i] = input.nextInt();
if(vetor[i] %2 == 0) {
contPar.append(i).append(" ");
} else {
contImpar.append(i).append(" ");
}
}
System.out.println("Números pares: " + contPar);
System.out.println("Números ímpares: " + contImpar);
}
}