Don't worry too much about efficiency here.
I ran this code 1 000 000 times with the result of 1.795s. (That's an average of .001795
milliseconds per time you randomize 5 numbers... trivial.)
Code:
for ( new i ; i < sizeof num ; i++ ) {
do num[i] = random_num(1, 10);
while ( AlreadyExists(num[i], num, i) )
}
// ...
AlreadyExists(num, array[], size) {
for ( new i ; i < size ; i++ )
if ( array[i] == num )
return 1;
return 0;
}
__________________