0
A
回答
4
rand(9) # this generator a number between 0 to 8
rand(0 .. 9) # this generator a number between 0 to 9
rand(1 .. 50) # this generator a number between 1 to 50
#rand(m .. n) # m is the start of generator number range, n is the end of generator number range
0
嘗試:
Array.new(5){rand 10}.join
優勢:
上面的代碼將產生5位隨機數。您可以根據您想要的位數取代5
。
相關問題
- 1. 使用Node.js生成隨機數頁面
- 2. 需要在每次頁面加載時生成隨機字母表
- 3. 在頁面加載/刷新時加載隨機頁面的腳本?
- 4. 在頁面重新加載頁眉時隨機出現中斷
- 5. 在頁面加載時隨計算機時間移動的DIV
- 6. 每次加載控制器時生成相同的隨機數
- 7. 自動加載隨機頁面
- 8. ViewPager中的WebViews隨機加載頁面
- 9. 頁面加載的隨機圖像
- 10. 隨機緩慢加載頁面
- 11. 頁面加載的隨機div
- 12. javascript - 頁面加載的隨機div?
- 13. 頁面加載的隨機圖像(jQuery)
- 14. 在頁面加載時,將隨機圖像放在div中
- 15. 在SHTML頁面中生成一個隨機數字
- 16. 在插入行時生成隨機數
- 17. 隨機數生成
- 18. 生成隨機數
- 19. 生成隨機數
- 20. 生成隨機數
- 21. 生成隨機數
- 22. 隨機數生成
- 23. 在Laravel生成隨機數
- 24. 隨機數生成在PySpark
- 25. 在「頁面加載」中加載一個隨機圖片
- 26. 在隨機生成50個隨機數中使用隨機數#
- 27. Javascript:如何在頁面加載時隨機化圖像
- 28. 嘗試在頁面加載時顯示隨機視頻
- 29. 在頁面加載生成QR碼
- 30. 隨機數生成機制
在你想要產生隨機數的地方使用rand。 – 2013-02-28 08:02:59