乘以随机数 [英] multiply random number

查看:157
本文介绍了乘以随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个函数rand()可以生成一个随机的整数

在0到100之间的数字。假设rand()非常昂贵。什么

是在0和

100之间产生10个不同随机数的最快方法? (只调用rand()10次......)


谢谢,


qq

Suppose I have a function rand() that can generate one integer random
number between 0 and 100. Suppose also rand() is very expensive. What
is the fastest way to generate 10 different random number between 0 and
100? (call rand() only 10 times...)

Thanks,

qq

推荐答案

快... @ yahoo.com写道:
quick...@yahoo.com wrote:
假设我有一个函数rand()可以随机生成一个整数
0到100之间的数字。假设rand()非常昂贵。什么
是在0和
100之间生成10个不同随机数的最快方法? (只调用rand()10次......)

谢谢,

qq
Suppose I have a function rand() that can generate one integer random
number between 0 and 100. Suppose also rand() is very expensive. What
is the fastest way to generate 10 different random number between 0 and
100? (call rand() only 10 times...)

Thanks,

qq




如果你'我不是在谈论标准函数std :: rand(),然后

你的帖子不在这里,因为它不关心C ++

语言或库。请参阅常见问题解答,了解主题:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9 。你可能想要一个处理算法的新闻组(例如,

comp.programming)或者一个处理随机数生成的新闻组。


干杯! --M



If you''re not talking about the standard function std::rand(), then
your post is off topic here since it is not concerned with the C++
language or libraries. See the FAQ for what is on-topic:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9. You
probably want a newsgroup dealing with algorithms in general (e.g.,
comp.programming) or one dealing with random number generation.

Cheers! --M


qu ****** @ yahoo.com 写道:
假设我有一个函数rand(),它可以生成一个0到100之间的随机数字整数。假设rand()非常昂贵。什么
是在0和
100之间生成10个不同随机数的最快方法? (只调用rand()10次......)
Suppose I have a function rand() that can generate one integer random
number between 0 and 100. Suppose also rand() is very expensive. What
is the fastest way to generate 10 different random number between 0 and
100? (call rand() only 10 times...)




是否存在隐藏在所有这些中的C ++语言问题?对于

一般编程问题考虑''comp.programming''。


如果你在谈论标准函数''rand'',那么它(a)没有
生成0到100个数字,它的限制是0和RAND_MAX,而(b)是

其实相当便宜。


V



Is there a C++ language question somewhere hiding in all this? For
general programming questions consider ''comp.programming''.

If you''re talking about the Standard function ''rand'', then it (a) doesn''t
generate 0 to 100 numbers, its limits are 0 and RAND_MAX, and (b) is in
fact quite inexpensive.

V


qu **** **@yahoo.com 写道:
假设我有一个函数rand(),可以生成0到100之间的一个随机整数。假设rand()也是非常贵。什么
是在0和
100之间生成10个不同随机数的最快方法? (只调用rand()10次......)

谢谢,

qq
Suppose I have a function rand() that can generate one integer random
number between 0 and 100. Suppose also rand() is very expensive. What
is the fastest way to generate 10 different random number between 0 and
100? (call rand() only 10 times...)

Thanks,

qq




我不喜欢我认为有可能解决这个问题,并保证只有

调用rand()10次。我错了。


john



I don''t think it is possible to solve that problem and guarantee to only
call rand() 10 times. I could be wrong.

john


这篇关于乘以随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆