返回列表 發帖
本帖最後由 沈子耕 於 2016-5-6 20:08 編輯
  1. public class Ch31{
  2.        public static void main(String args[]){
  3.               for(int i=1; i<=20; i++){
  4.                       int s=(int)(Math.random()*3)+1;
  5.                       System.out.println(s);
  6.               }
  7.        }
  8. }
複製代碼
ABCDEFGHIJKLMNOPQRSTUVWXYZ

TOP

  1. import java.util.Random;
  2. public class Ch32{
  3.        public static void main(String args[]){
  4.               Random r=new Random();
  5.               for(int i=1; i<=20; i++){
  6.                       System.out.println(r.nextInt(3)+1);
  7.               }
  8.        }
  9. }
複製代碼
ABCDEFGHIJKLMNOPQRSTUVWXYZ

TOP

返回列表