返回列表 發帖

亂數 (一)

本帖最後由 鄭繼威 於 2022-11-26 09:43 編輯

運用 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. }
複製代碼

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

  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. }
複製代碼

TOP

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

TOP

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

TOP

  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. }
複製代碼

TOP

返回列表