常见问题主题 - 如何生成从1到N的随机整数? [英] FAQ Topic - How do I generate a random integer from 1 to N?
问题描述
----------------------------------------------- ------------------------
常见问题解答主题 - 如何生成从1到
$的随机整数b $ b N?
------------------------------------- ----------------------------------
函数随机(x ){return Math.floor(x * Math.random())}
给出一个0到x-1(包括0和x-1)范围内的随机整数;使用
= AB随机(N)+1 = BB为1到N.
http://msdn.microsoft.com/ library / de ... 5ee4652cd7.asp
http://docs.sun.com/source/816-6408-10/math.htm
如何处理和Shuffle:
http:// www.merlyn.demon.co.uk/js-randm.htm
===
这样的发布每天自动发送一次。他们的b
目标是回答重复的问题,并将内容提供给社区进行持续评估/改进。完整的
comp.lang.javascript常见问题解答位于 http: //jibbering.com/faq/index.html 。
FAQ工作人员是一群志愿者。
-----------------------------------------------------------------------
FAQ Topic - How do I generate a random integer from 1 to
N?
-----------------------------------------------------------------------
function Random(x) { return Math.floor(x*Math.random()) }
gives a random integer in the range from 0 to x-1 inclusive; use
=AB Random(N)+1 =BB for 1 to N.
http://msdn.microsoft.com/library/de...5ee4652cd7.asp
http://docs.sun.com/source/816-6408-10/math.htm
How to Deal and Shuffle:
http://www.merlyn.demon.co.uk/js-randm.htm
===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers.
推荐答案
常见问题解答服务器在2007年2月27日下午7:00说:
FAQ server said the following on 2/27/2007 7:00 PM:
---------- -------------------------------------------------- -----------
常见问题解答主题 - 如何生成1到
N的随机整数N?
-------------------------------------------------- ---------------------
函数Random(x){return Math.floor(x * Math.random( )}}
给出0到x-1(含)范围内的随机整数;使用
= AB随机(N)+1 = BB为1到N.
-----------------------------------------------------------------------
FAQ Topic - How do I generate a random integer from 1 to
N?
-----------------------------------------------------------------------
function Random(x) { return Math.floor(x*Math.random()) }
gives a random integer in the range from 0 to x-1 inclusive; use
=AB Random(N)+1 =BB for 1 to N.
Bart,你的脚本再次被打破:(
-
兰迪
机会有利于准备好的心灵
comp.lang.javascript常见问题 - http://jibbering.com/faq/index.html
Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb写道:
Randy Webb wrote:
FAQ服务器在2007年2月27日发表以下内容晚上7:00:
FAQ server said the following on 2/27/2007 7:00 PM:
> = AB随机(N)+1 = BB代表1到N.
>=AB Random(N)+1 =BB for 1 to N.
Bart,你的剧本再次被打破:(
Bart, your script is broken again :(
是的。我现在肯定会选择`(hex 60)来保持它
仅限ASCII。
-
Bart
Yes. I''m now definitely gonna choose for ` (hex 60) as to keep it
ASCII-only.
--
Bart
在comp.lang.javascript消息中< 45 *********************** @ news.sunsite。
dk>,星期三,2007年2月28日00:00:02,常见问题解答服务器< ja ******** @ dotinternet.be>
发布:
In comp.lang.javascript message <45***********************@news.sunsite.
dk>, Wed, 28 Feb 2007 00:00:02, FAQ server <ja********@dotinternet.be>
posted:
> http://msdn.microsoft.com/library/de...3D/library/en-
us / script56 / html / a28c5c66-c42f-4082-9b71-9a5ee4652cd7.asp
>http://msdn.microsoft.com/library/de...3D/library/en-
us/script56/html/a28c5c66-c42f-4082-9b71-9a5ee4652cd7.asp
给我一个啰嗦404.
< http:// www .elsop.com / quick / quick.cgigives,检查常见问题解答URL,
在Microsoft Script Debugger Download:之后,3.2结束:
00585错误:未找到404 http://msdn.microsoft.com/downloads / list / web
dev.asp http://msdn.microsoft.com/downloads/list [Redir: http:/ /msdn.mic
rosoft.com/404/default.aspx]
4.38:
01478警告:908缺少/ http://www.ajaxtoolbox.com
在4.44:
01626警告:908缺少/ http:// www .ajaxtoolbox.com
但最后两个没有出现在我当地的FAQ副本中 - 9.5 -
2007-01-23
Gives me a long-winded 404.
<http://www.elsop.com/quick/quick.cgigives, checking FAQ URL,
Just after "Microsoft Script Debugger Download:", end of 3.2 :
00585 Error: 404 Not Found http://msdn.microsoft.com/downloads/list/web
dev.asp http://msdn.microsoft.com/downloads/list [Redir: http://msdn.mic
rosoft.com/404/default.aspx]
In 4.38 :
01478 Warning: 908 Missing / http://www.ajaxtoolbox.com
In 4.44 :
01626 Warning: 908 Missing / http://www.ajaxtoolbox.com
but the last two do not appear on my local copy of FAQ - 9.5 -
2007-01-23
> http://docs.sun.com/source/816-6408-10/math.htm
提供虚假信息。说介于0和1之间。还说从当前时间播种
这可能是一般的,但不是一个语言要求。我建议参考标准,15.8.2.14,
或只是复制这三行。
Gives false information. Says "between 0 and 1". Also says "seeded
from the current time" which is probably generally true but is not a
language requirement. I suggest a reference to the standard, 15.8.2.14,
or just copying those three lines.
>如何处理和随机播放:
>How to Deal and Shuffle:
可以视为暗示该页面仅* *关于此。修复是
添加查看。
Could be taken as implying that the page is *only* about that. Fix is
to add "See in".
> http://www.merlyn.demon.co.uk/js-randm.htm
顺便说一句,有权访问Vista的人是否会在IE中检查一个网页
?这只是报告某些计算文本所说的问题。
-
(c)John Stockton,英国萨里。 ?@merlyn.demon.co.uk Turnpike v6.05 MIME。
Web< URL:http://www.merlyn.demon.co.uk/- FAQqish topics,acronyms&链接;
Astro的东西通过astron-1.htm,gravity0.htm; quotings.htm,pascal.htm等。
无编码。回复之前的行情。剪得好。写清楚。不要邮寄新闻。
By the way, would anyone with access to Vista care to check a Web page
in IE? It''s just a matter of reporting what certain computed text says.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don''t Mail News.
这篇关于常见问题主题 - 如何生成从1到N的随机整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!