![]() |
【求助】如何产生0到8之间的整数随机数?
如何产生0到8之间的整数随机数?
谢谢 |
randperm(8)
从里面随便取一个就可以了。 |
[QUOTE=dnping;3190]randperm(8)
从里面随便取一个就可以了。[/QUOTE] 这个ms只能把1~8随机排好哦 |
round(8*rand)
|
random('unid',9)-1
|
x = randint(8);
|
>> randint(8)
ans = 1 0 1 0 0 0 0 1 1 1 0 0 0 0 1 0 0 1 0 1 1 1 1 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 1 1 0 0 0 1 0 0 1 0 1 1 0 0 1 1 |
randint不是很恰当
要实现的话,建议语句 randint(1,1,9) |
randperm(8)只是将1到8的整数随机排列
|
所有时间均为北京时间。现在的时间是 12:15。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.