This is part 2 of an earlier post.
I know how to create a 5x5 array. I am just having problems with part where they can occur one time.
I hope someone can help.
In this task, you will generate a 5×5 array and fill it with random integers between 0 and 24 inclusive and each number should occur exactly once.
void MultiU (){
int size = 5;
int multiU[5][5];
srand(time(0));
for (int row = 0; row < size; row++){ //creates the 5x5 board
for (int column = 0; column < size; column++){
multiU[row][column] = rand() %25;
}
}
for (int row = 0; row < size; row++){ //thought this would check to see if the number occurred and if it did then it would assign it a new random number but it did not work
for (int column = 0; column < size; column++){
if (multiU[row][column]== multiU[row][column+1]){
multiU[row][column] = rand() %25;
}
}
} //where I would output the array
for (int row = 0; row < size; row++){
for (int column = 0; column < size; column++){
cout << multiU [row][column]<< ' ';
}
cout << endl;
}
}