lundi 26 avril 2021

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(){
    ...
}



Aucun commentaire:

Enregistrer un commentaire