2
I should present only the numbers present in the odd vector positions, but I’m stuck:
package pag1;
import java.util.Scanner;
import java.util.Arrays;
public class ex1 {
public static void main (String[] args){
Scanner x = new Scanner (System.in);
int posicao = 0;
int[] numeros = new int[10];
System.out.println("Digite 10 números inteiros seguidos:");
while(posicao <= 9){
numeros [posicao] = x.nextInt();
posicao++;
}
System.out.println(Arrays.toString(numeros));
}
}
When showing only the numbers that are in odd positions I don’t know how, just show all vector positions.
Start the counter position at 1 and add 2 in each iteration, so you go to positions 1, 3 ,5 ,7 ,9
– João Silva