zoukankan      html  css  js  c++  java
  • java第六次作业(老师讲过后)

    import java.util.*;

    public class Draw {
    private ArrayList list;
    public Draw() {
    list= new ArrayList();
    }
    public void deal(int num) {
    //向容器中添加奖券(使用循环)

    		for (int j = 0; j<= num ; j++) {
    			 list.add(j);
    		
    	}
    	//打乱顺序
    	Collections.shuffle( list);
    }
    public void drawLottery(int n){
      Random ra = new Random();
    	
      for(int i=0;i<n;i++){
      int index =ra.nextInt(list.size());
      System.out.print(list.get(index)+"	");
      list.remove(index);
      }
      System.out.println();
      }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	Draw c = new Draw();
    	
    	c.deal(100);
    	System.out.println("————————一等奖————————");
    	c.drawLottery(2);
    	System.out.println("————————二等奖————————");
    	c.drawLottery(5);
    	System.out.println("————————三等奖————————");
    	c.drawLottery(10);
    }
    

    }

  • 相关阅读:
    [纯奇技淫巧] 特征根
    杂题20200528
    杂题20200509
    杂题20200419
    杂题20200415
    杂题20200407
    杂题20200314
    Educational Codeforces Round 83 简要题解
    一种简单的dp trick
    杂题20200304
  • 原文地址:https://www.cnblogs.com/shemai/p/5499095.html
Copyright © 2011-2022 走看看