Array de enteros aletorios
Publicado por Hector (4 intervenciones) el 07/11/2007 20:36:49
Hola a todos tengo un pequeño problema estoy intentando crear un array de 90 numeros aleatorios no repetidos y no se que hago mal a ver si alguien me puede ayudar aqui les dejo el codigo tal y como lo tengo que hace todo menos no repetir los numeros gracias de antemano
int bolas[89];
bool num[89];
int j = 0;
for (int q=0;q<90;q++)
num[q] = false;
for (int i = 0;i< 90;i++){
j = rand () % 91;
for ( int y=0;y<90;y++){
if(j == bolas[i])
if (num[i] == true)
j++;}
bolas[i] = j;
num[i] = true;
}
int bolas[89];
bool num[89];
int j = 0;
for (int q=0;q<90;q++)
num[q] = false;
for (int i = 0;i< 90;i++){
j = rand () % 91;
for ( int y=0;y<90;y++){
if(j == bolas[i])
if (num[i] == true)
j++;}
bolas[i] = j;
num[i] = true;
}
Valora esta pregunta


0