|
srand(time(NULL) % getpid() );
And DaWei is correct. You want
int choice= rand()%2;
choice ++;
This gives 1 or 2.
If you really want .0 ... .999999 then
double choice=rand();
double next=rand();
choice=(next > choice) ? choice/next : next/choice;
or use something like drand48();
|