返回列表 發帖

亂數 (二)

本帖最後由 tonyh 於 2012-10-8 20:47 編輯

利用Math.random()函數, 搭配for迴圈, 產生20組範圍介於0.00000~0.99999(無窮小數)的隨機亂數.
  1. public class ch20
  2. {
  3.   public static void main (String args[])
  4.   {
  5.       for(int i=1; i<=20; i++)
  6.       {
  7.             System.out.println(Math.random());
  8.       }
  9.   }
  10. }
複製代碼

返回列表