You are on page 1of 1

public static void main(String[] args) {

// TODO code application logic here


int i, j;
int v[] = new int[10];
for (i = 0; i < v.length; i++) {
v[i] = Integer.parseInt(JOptionPane.showInputDialog("Ingrese nmeros"));
System.out.println("En la posicin " + i + ": " + v[i]);
}
/*
* --------INSERCCION
*/
for (i = 1; i < v.length; i++) {
int temporal = v[i];
for (j = i - 1; j >= 0 && v[j] < temporal; j--) {
v[j + 1] = v[j];
}
v[j + 1] = temporal;
}
System.out.println("Array de primos ordenados:");
for (i = 0; i < v.length; i++) {
int multiplos = 0;
for (j = 1; j < v.length; j++) {
if (v[i] % j == 0) {
multiplos++;
}
if (multiplos == 2 && j == (v.length-1)) {
System.out.println(v[i] + " ");
}
}
}
}

You might also like