抽奖系统(二)

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)+"\n");
    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)+"\n");
	    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)+"\n");
}





}
}

posted @ 2016-05-12 08:54  2014330122王伟华  阅读(132)  评论(0编辑  收藏  举报