the easiest way i feel...
int myrand(int x)
{
int y=rand()%100;
if(y<x)
return 1;
return 0;
}
Given x, less than 100. How will you generate true with probability x/100.
最新推荐文章于 2021-02-23 13:55:47 发布
the easiest way i feel...
int myrand(int x)
{
int y=rand()%100;
if(y<x)
return 1;
return 0;
}