ysq101 发表于 2015-1-3 21:49:41

没玩过随机这玩意。用表中随机抽出1个数出来。。

(1 2 3 4 5 6 7 8 9 10 11 12)
从表中随机抽出1个数出来。。
这该怎么写??

819534890 发表于 2015-1-3 23:33:36

;;; 求随机数(0~1)--by 狂刀
(defun th-rnd ()                     ; 随机数种子
(* (rem (getvar "cputicks") 1e3) 1e-3)
)

_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
2
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
7
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
11
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
2
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
10
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
3
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
3
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
9
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
8
_$ (nth (fix (* (th-rnd) 12)) '(1 2 3 4 5 6 7 8 9 10 11 12))
1

lsjj 发表于 2015-1-4 10:01:22

本帖最后由 lsjj 于 2015-1-4 10:04 编辑

Nth 12會出現嗎?
页: [1]
查看完整版本: 没玩过随机这玩意。用表中随机抽出1个数出来。。