this array will contain 1 to 100 numbers. every number must just 1 time used (control will make with another function) and made with rand() function. i tried to use recursive function but i couldnt. can anybody help me?
recursion is usually just a confusing way to write a loop.
100 is small enough that while idiotic, you can brute force it..
roughly ...
int get_value()
{
static char used[101] = {0};
int r = 0;
while(used[r] == 0)
r = rand()%100+1;
used[r] = 1;
return r;
}
for(x = 0; x < 10; x++)
for(y = 0; y < 10; y++)
array[x][y] = get_value();
can you do it cleaner though? It will start to act up when there are less than 10 numbers left in the pool as it tries to randomly roll the last one a half billion times or something.