Board logo

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

作者: tonyh    時間: 2020-11-21 11:18     標題: 亂數 (二)

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

作者: 龔品誠    時間: 2020-11-21 11:43

  1. public class QUQ
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.             System.out.println(Math.random());
  7.     }
  8. }
複製代碼

作者: 林羿丞    時間: 2020-11-21 11:45

  1. public class Ch666
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.             System.out.println(Math.random());
  7.     }
  8. }
複製代碼

作者: 王銘鴻    時間: 2020-11-21 11:45

  1. public class Ch31
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.             System.out.println(Math.random());
  7.     }
  8. }
複製代碼

作者: 陳莉榛    時間: 2020-11-21 11:47

  1. public class Ch555
  2. {
  3.     public static void main(String args[])
  4.     {
  5.      for(int a = 1;a<=20;a++)
  6.      {
  7.        System.out.println(Math.random());
  8.      }

  9. }
  10. }
複製代碼

作者: 李穎俊    時間: 2020-11-21 11:47

  1. public class h
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.             System.out.println(Math.random());
  7.     }
  8. }
複製代碼

作者: 黃柏智    時間: 2020-11-28 09:47

  1. public class A02
  2. {
  3.   public static void main(String args[])
  4.   {
  5.     double r;

  6.     r= Math.random();
  7.     for(int i=1;i<=20;i++)
  8.     System.out.println(r);
  9.   }
  10. }
複製代碼

作者: 張淯祺    時間: 2020-11-30 18:23

  1. public class h2
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.             System.out.println(Math.random());
  7.     }
  8. }
複製代碼





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