Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- srand(time(0)); // iniciando la semilla aleatoria
- // Formula a + rand() % (b-a+1)
- // eligiendo 15 numeros aleatorios distintos entre 1 y 50
- for(i=0;i<15;i++)
- {
- // Genera numero aleatorio
- int num = 1 + rand()%50;
- if(i>0)
- {
- // Verifica si no se ha generado antes
- for(j=0; j < i; j++)
- if(num==vector[j])
- {
- num = 1 + rand()%50;
- j=-1;
- }
- }
- vector [ i ] =num;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement