Board logo

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

作者: tonyh    時間: 2012-9-29 17:00     標題: 亂數 (四)

本帖最後由 tonyh 於 2012-9-29 17:16 編輯

產生20組範圍介於123~127之整數隨機亂數.
  1. public class ch33
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.         {
  7.             System.out.println((int)(Math.random()*5+123));    //123~127
  8.         }
  9.     }
  10. }
複製代碼

作者: t2364705    時間: 2012-9-29 17:07

  1. public class ch33
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.         {

  7.             System.out.println((int)(Math.random()*5+123));
  8.         }
  9.     }
  10. }
複製代碼

作者: t3742238    時間: 2012-9-29 17:09

  1. public class ch33
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.         {

  7.             System.out.println((int)(Math.random()*5+123));
  8.         }
  9.     }
  10. }
複製代碼

作者: 粘靖瑜    時間: 2012-9-29 17:09

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

作者: 劉漢文    時間: 2012-9-29 17:10

  1. public class ch33
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.         {

  7.             System.out.println((int)(Math.random()*5+123));
  8.         }
  9.     }
  10. }
複製代碼

作者: 尤泓鈞    時間: 2012-9-29 17:13

  1. public class ch33
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.         {

  7.             System.out.println((int)(Math.random()*5+123));
  8.         }
  9.     }
  10. }
複製代碼

作者: 蔡昀佑    時間: 2012-9-29 17:15

  1. public class ch33
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=20; i++)
  6.         {

  7.             System.out.println((int)(Math.random()*5+123));
  8.         }
  9.     }
  10. }
複製代碼

作者: 黃博鴻    時間: 2012-10-27 15:22

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





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