#### 6*6 int array number generator with specific numbers

I want to make a 6*6 int array (global array), which has 36 numbers.

The 36 numbers must include 1, 2, 3, …, 17, 18 and each number cannot appear more than twice.
They need to be generated in totally random orders, e.g. no {1, 1, 2, 2, 3, 3, …}, {1, 2, 3, …, 1, 2, 3, …}…
Each time it can generate different random orders.

How to efficiently make a void function of this?

The compiling time must be as short as possible.
Only rand() and simple things can be used (for, while, if, do-while).

``````int array[6][6];
void numberGenerator(){
int numberPool[36]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};
int usedNumber[36]={0, 0, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for(int i=0;i<6;i++){
for(int j=0;j<6;j++){
while(1){
int a=rand()%36;
if(usedNumber[a]==0){
usedNumber[a]=1;
array[i][j]=numberPool[a];
break;
}
}
}
}
}
``````

Edit: This is what i comes up with… But is there any better solution?

Source: Windows Questions C++