Last active
September 5, 2017 16:46
-
-
Save jimywork/7eaff09d5c6818fb8039f003085ebad8 to your computer and use it in GitHub Desktop.
Lista de Exercícios Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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