Board logo

標題: 亂數 (一) [打印本頁]

作者: tonyh    時間: 2017-2-25 10:34     標題: 亂數 (一)

運用 random() 函式, 產生一範圍介於 0.00000 (趨近於0) ~ 0.99999 (趨近於1) 之隨機亂數.
用此語法產生的亂數, 其資料形態為 double.
  1. public class Ch30
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         double r;
  6.         r=Math.random();
  7.         System.out.println(r);
  8.     }
  9. }
複製代碼

作者: 黃茂勛    時間: 2017-2-25 10:52

  1. public class Ch30
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         double r;
  6.         r=Math.random();
  7.         System.out.println(r);
  8.     }
  9. }
複製代碼

作者: 陸長辰    時間: 2017-2-25 10:52

  1. public class Ch26
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         double r;
  6.         r=Math.random();
  7.         System.out.println(r);
  8.     }
  9. }
複製代碼

作者: 林侑成    時間: 2017-2-25 10:55

  1. public class Edit5

  2. {
  3.     public static void main(String args[])
  4.     {
  5.         double r;
  6.         r=Math.random();
  7.         System.out.println(r);
  8.     }
  9. }
複製代碼

作者: 陳泓瑜    時間: 2017-2-25 11:15

  1. public class Ch24
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         double r;
  6.         r=Math.random();
  7.         System.out.println(r);
  8.     }
  9. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2