返回列表 發帖

亂數 (一)

運用 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. import java.util.Scanner;

  2. public class Ch05 {

  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 Ch124 {

  2.         public static void main(String[] args) {
  3.                 double x;
  4.                 x=Math.random();
  5.                 System.out.println(x);
  6.         }

  7. }
複製代碼

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 Ch14 {

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

  8. }
複製代碼

TOP

  1. package ok;

  2. import java.util.Scanner;

  3. public class foradd2 {

  4.         public static void main(String[] args) {
  5.                 double r;
  6.                 r=Math.random();
  7.             System.out.println(r);
  8.         }

  9. }
複製代碼

TOP

  1. package Ch01;

  2. import java.util.Scanner;

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

TOP

  1. public class Ch30 {

  2.         public static void main(String[] args) {
  3.                 double r;
  4.                 r=Math.random();
  5.                 System.out.println(r);
  6.                                

  7.         }

  8. }
複製代碼

TOP

  1. public class Ch02 {

  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 CH02
  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 Ch00
  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. import java.io.Console;

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

TOP

  1. public class Ch87 {

  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 r;
  6.         r=Math.random();
  7.         System.out.println(r);
  8.     }
  9. }
複製代碼

TOP

  1. public class Ch30 {

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

  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

  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 ch01
  2. {
  3.     public static void main(String arg[])
  4.     {
  5.         double r;
  6.         r=Math.random();
  7.         System.out.println(r);
  8.     }
  9. }
複製代碼
我好帥
我超級帥
我非常的帥
我宇宙第一帥

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 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

返回列表