Hello I have an array that is formed by a set of random numbers. Yet some of these sets of numbers overlap. What can I do to prevent this from happening?
void ransnipa(int (*board)[40]){
srand(time(NULL));
int k;
int x[snipa];
int y[snipa];
for(k=0 ; k < snipa ;k++){
x[k]= rand() % 39;
y[k]= rand() % 39;
do{
x[k]= rand() % 39;
y[k]= rand() % 39;
}while(( (board[x[k]][y[k]]) && (board[x[k]+1][y[k]]) && (board[x[k]+1][y[k]+1]) && (board[x[k]][y[k]+1])) == -1);
board[x[k]][y[k]]=2;
board[x[k]+1][y[k]]=2;
board[x[k]+1][y[k]+1]=2;
board[x[k]][y[k]+1]=2;
}
}
void rantank(int (*board)[40]){
srand(time(NULL));
int k;
int x[tank];
int y[tank];
int ant;
for(k=0 ; k < tank ;k++){
x[k]= rand() % 39;
y[k]= rand() % 39;
do{
x[k]= rand() % 39;
y[k]= rand() % 39;
}while(((board[x[k]][y[k]]) && (board[x[k]+1][y[k]]) && (board[x[k]+1][y[k]+1]) && (board[x[k]][y[k]+1]) && (board[x[k]][y[k]-1]) && (board[x[k]+1][y[k]-1]) && (board[x[k]-1][y[k]-1]) && (board[x[k]-1][y[k]]) && (board[x[k]-1][y[k]+1])) == -1);
board[x[k]][y[k]]=3;
board[x[k]+1][y[k]]=3;
board[x[k]+1][y[k]+1]=3;
board[x[k]][y[k]+1]=3;
board[x[k]][y[k]-1]=3;
board[x[k]+1][y[k]-1]=3;
board[x[k]-1][y[k]-1]=3;
board[x[k]-1][y[k]]=3;
board[x[k]-1][y[k]+1]=3;
}
}