Oi Gente,
Estou com um problema quando tento gerar um vetor de números aleatórios.
Tenho uma matriz(Ma), que corresponde as posições de corredores.
As posições mudam a cada volta(vetor aleatório).
Não consigo gera-lo
Desde já agradeço a ajuda :)
int atualiza_posicao(int i, int j){
int cont_linha=0, x=0;
srand(time(NULL));
x = (rand()%j)+1;
for(int l=0; l<j; l++){
if(Ma[l] == x){
x = (rand()%5)+1;
l=0;
}
}
cout << x ;
return x;
}
void cria_matriz(int n){
for(int i=0; i<voltas; i++){
for(int j=0; j<n; j++){
if(i == 0){
Ma[j] = largada[j];
}else{
Ma[j] = atualiza_posicao(i, j);
}
}
}
}