抽奖系统(二)

package lotterydraw;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class lotterDraw {

public static void main(String[] args) {
	ArrayList <Integer> number = new ArrayList<>();
    Random random = new Random();


     for(int i=0;i<2000;i++){
	    int A=i;
      	number.add(A);
    }
    Collections.shuffle(number);
    int A = random.nextInt(2000);
    System.out.println("一等奖:"+number.get(A)+"
");
    number.remove(A);
    for(int i=1;i<3;i++){
     	Collections.shuffle(number);
	    int B = random.nextInt(2000-i);
	    System.out.println("二等奖;"+number.get(B)+"
");
	    number.remove(B);


}

    for(int i=1;i<4;i++){
	    Collections.shuffle(number);
	    int B = random.nextInt(1997-i);
	    System.out.println("三等奖;"+number.get(B)+"
");
}





}
}

原文地址:https://www.cnblogs.com/2014330122wwh/p/5484348.html