Dear everyone,
For those who replied on my thread, thank you so much. I was not able to visit this site for a while that's why I am surprised to have many replies from you all, actually my last reading is on Mr. King Mir reply, that's why I clicked his link Shuffleing algorithms can be found on Google, and I visited one of the site and I tried to apply its code, here it is (with some little modifications):
Code:
#include<stdio.h>
int main()
{
int i, j, k;
for (i = 0; i < 9; i++)
num[i] = i; /*assign 0 to num[0], assign 1 to num[1], and so on...*/
for (i = 0; i < 9; i++) {
j = rand() % n;
k = num[i];
num[i] = num[j];
num[j] = k;
}
}
And it works, although it seems that the same arrangement of randoming numbers we're encountered, but at least there were no more repeating value encountered, that is, no more two 4's, three 5's, etc. (may be it's because I initialized them before I shuffled it). As I have read again this thread, I guess this what's laserlight is telling beforehand, to "populate" first the array, then do the shuffling.
But nevertheless, I am already contented with the result. I'll try everyones codes as another workarounds in this related problem. Any way, any more tutorial on what this rand() function? I know it's a randoming function, but I want to know about it more.
Thank you and more power to everyone.
Respectfully Yours,
MarkSquall