samedi 13 juillet 2019

Writing random numbers with no duplicate using only Random without ArrayList

I have a problem to write more lucidity program for random numbers without repeating. My code works but its not really nice.

I tried many thinks especially i just played with loops

for(int i=1; i<=pole.length;i++){

while(p<=13){
i=rd.nextInt(13)+1;
if(pole[i]==i){    
}
    else{
    System.out.println`(i+"-"+p);
    pole[i]=i;
    p++;
    if(i>Max){
    Max=i;}
    }
    i=Max;
    }

I expect 13 numbers without repeating this one works but how to write it easier




Aucun commentaire:

Enregistrer un commentaire