Mail Archives: djgpp/1999/05/01/21:22:58
Hello experts!
Hi have written a program that use random functions.
But the randomizer doesn't work!
Here a little part of my code:
the variable of subjekt_file_line_counter=17;
-----------------------
void randomizer()
{
subjekt_rnd=0;
verb_rnd=0;
name_rnd=0;
rerandomizesubjekt:
subjekt_rnd=(rand() & (subjekt_file_line_counter)); // random subjects
if (subjekt_rnd==0) { goto rerandomizesubjekt; }
rerandomizeverb:
verb_rnd=(rand() & (verb_counter)); // random subjects
if (verb_rnd==0) { goto rerandomizeverb; }
rerandomizename:
name_rnd=(rand() & (name_counter)); // random subjects
if (name_rnd==0) { goto rerandomizename; }
}
...
...
int main()
{
...
srandom(5000000);
randomizer();
}
-----------
The result is that he repeat the same number what are generated!
Here is the result of subjekt_rnd:
1 16 2 19 18 16 2 18 1 17 17 17 2 16 3 17 17 16 16 16 2 1 17 16 16 19 17
1 1 19
1 3 2 1 16 16 16 2 18 3 3 19 19 17 16 17 16 17 1 1 3 1 2 16 2 3 16 3 16
16 16 16
17 2 1 17 19 2 1 17 18 2 3 19 18 2 18 2 16 16 1 2 18 1 19 19 1 18 1 16
16 17 18
17 2 2 2 1 2 16 19 17 3 17 18 1 17 2 2 3 16 19 1 19 2 17 19 18 16 3 3
16 1 3 19
19 18 19 16 17 17 18 1 16 1 2 2 2 19 18 2 1 19 3 1 19 1 19 17 19 19 16
2 17 19
3 16 1 19 1 18 19 2 19 17 3 16 3 1 17 17 18 1 18 1 2 18 17 19 1 19 3 2 3
2 2 3 1
8 3 18 19 2 17 3 19 1 18 16 1 1 2 17 3 19 19 19 17 1 16 19 17 17 18 2 17
16 2 18
2 3 17 2 2 19 17 3 1 2 17 19 18 16 19 2 17 17 3 16 18 17 1 19 1 3 3 17
17 17 2
18 18 17 3 19 18 19 3 18 2 18 18 18 18 1 16 3 1 1 1 1 1 1 1 19 18 1 17 1
1 18 2
17 2 16 2 19 2 2 1 19 17 19 17 1 16 2 17 2 3 16
There is not the number: 4,5,6,7,8,9,10,11,12,13,14,15,etc...!!!
Where is the problem ???
The randomizer doesn't work correctly ???
Stephan Ferraro
- Raw text -