Skip to content

Instantly share code, notes, and snippets.

@jimywork
Last active September 5, 2017 16:46
Show Gist options
  • Save jimywork/7eaff09d5c6818fb8039f003085ebad8 to your computer and use it in GitHub Desktop.
Save jimywork/7eaff09d5c6818fb8039f003085ebad8 to your computer and use it in GitHub Desktop.
Lista de Exercícios Java
// Faça um programa que preencha um vetor de nove elementos numéricos inteiros, calcule e mostre os números
// PARES e suas respectivas posições.
import java.util.Random;
class Main {
public static void main(String[] agrs) {
int vetor[] = new int[9];
Random primes = new Random();
for(int i = 1; i < vetor.length; i++) {
vetor[i] = primes.nextInt(0x1F);
if(vetor[i] % 2 == 0) {
System.out.printf("Número primo %d está na posição %d\n", vetor[i], i);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment