“`”

参考回答:

<pre><code>function g(x)
{
int v = f(x) + f(x)>0?0:1;
if(v==0)
{
return 0; //1.f(x),f'(x)同时为0
}
else if(v==2)
{
return 1; //2.f(x),f'(x)同时为1
}
else
{
g(x); //3.f(x),f'(x)一个为0一个为1,重新生成随机数
}
}
</code></pre>

新的rand函数中:调用一次,while循环的期望次数是2。

<pre><code> "“`

Was this helpful?

0 / 0

发表回复 0

Your email address will not be published.