I am trying to solve this exercise but I am facing some problems while trying to do so. In logical terms, I think that I am thinking right. Could you take a look at my code please and try to help me?
Thanks!
import java.util.Arrays; import java.util.Random;
public class exercicio_4_alapata { public static void main(String[] args) {
int [] Array_numal;
Array_numal = new int [100];
int [] ArrayOrdenado;
ArrayOrdenado = new int [100];
int posicao_array;
int posicao_array2 = 0;
for (posicao_array = 0; posicao_array < Array_numal.length; posicao_array ++) {
Random rand = new Random();
Array_numal [posicao_array] = rand.nextInt(101);
}
int maior = Array_numal [0];
while (maior != ArrayOrdenado[99]) {
for (posicao_array2 = 0; posicao_array2 == 99; posicao_array2 ++) {
for (posicao_array = 0; posicao_array < Array_numal.length; posicao_array ++) {
if ((Array_numal[posicao_array] > maior) && (maior < ArrayOrdenado [posicao_array2 - 1])) {
maior = ArrayOrdenado [posicao_array2];
}
}
}
}
for (posicao_array2 = 0; posicao_array2 < ArrayOrdenado.length; posicao_array2 ++) {
System.out.println(ArrayOrdenado[posicao_array2]);
}
}
}
Aucun commentaire:
Enregistrer un commentaire