欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

Java實現彩票程序

錢瀠龍2年前18瀏覽0評論

Java實現彩票程序?

import Java.util.ArrayList;import java.util.Collections;import java.util.List;import java.util.Random;public class Main { public static void main(String[] args) { //紅球 33 選6 List<Integer> redBall = new ArrayList<Integer>(); for(int i=0;i<33;i++){ redBall.add(i+1); } System.out.println("開獎紅球:" + select(redBall, 6)); //籃球16選1 List<Integer> blueBall = new ArrayList<Integer>(); for(int i=0;i<16;i++){ blueBall.add(i+1); } System.out.println("開獎藍球:" + select(blueBall, 1)); } public static List<Integer> select(List<Integer> list,int count){ List<Integer> selectedList = new ArrayList<Integer>(); Random random = new Random(); for(int i=0;i<count;i++){ int index = random.nextInt(list.size()); Integer number = list.get(index); selectedList.add(number); list.remove(index); } Collections.sort(selectedList); return selectedList; }}

java util包,Java實現彩票程序