美文网首页
球队分组

球队分组

作者: 吴鹏608 | 来源:发表于2018-01-10 15:38 被阅读0次

public class countryGroup {
    public static void main(String[] args) {
        Map<Integer,List<String>> Integer2Countrys = new HashMap<Integer,List<String>>();
        List<String> ListCountry = new ArrayList<String>();
        String country = "科特迪瓦,阿根廷,澳大利亚,塞尔维亚,荷兰,尼日利亚,日本,美国,中国," +
                "新西兰,巴西,比利时,韩国,喀麦隆,洪都拉斯,意大利";
        String[] countrys = country.split(",");
        for (String string:countrys){
            ListCountry.add(string);
        }
        for (int j = 0;j < 4;j++){
            List<String> listcountrygroup = new ArrayList<String>();
            for (int i = 0;i < 4;i++){
                Random random = new Random();
                int index = random.nextInt(ListCountry.size());
                listcountrygroup.add(ListCountry.get(index));
                ListCountry.remove(index);
            }
            Integer2Countrys.put(j+1,listcountrygroup);
        }
        for (Integer in : Integer2Countrys.keySet()){
            System.out.println("第"+in+"组");
            for (String str :Integer2Countrys.get(in)){
                System.out.print(str+"  ");
            }
            System.out.println();
        }
    }
}

相关文章

网友评论

      本文标题:球队分组

      本文链接:https://www.haomeiwen.com/subject/xyponxtx.html