首页 技术 正文
技术 2022年11月18日
0 收藏 514 点赞 3,801 浏览 2015 个字

//打乱学生顺序

Collections.shuffle();

容我记个单词

peer:

vi.
凝视; 盯着看; 隐退,若隐若现; 同等,比得上;
n.
同辈,同等的人; 贵族; 同伴,伙伴;
adj.
贵族的; (年龄、地位等)同等的; 相匹敌的;

PEER-TO-PEER:同等延迟机制。根据网络中共享资源方式的不同,局域网有两种组织形式

package com.itzerone.name;

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

public class SortTeam {

public static void main(String[] args) {

// 学生集合
List<String> student = new ArrayList<String>();
// 学生数据
String[] names = { “xxX”,”xxx”,”xxx”,”xxxx”,”xxx”,”xxx” };

// 遍历
for (String stuNum : names) {
student.add(stuNum);

}
// 打乱学生顺序
Collections.shuffle(student);

// 学生41人,5人一组,留1人
List<String> one = new ArrayList<String>();// 一个人一组的人
Random random = new Random();
int index = random.nextInt(student.size());
String oneStu = student.remove(index);
one.add(oneStu);

// 41人除去1人还有40人
// 把每组的人存在List集合
List<String> oneTeam = new ArrayList<String>();// 一组
List<String> twoTeam = new ArrayList<String>();// 二组
List<String> threeTeam = new ArrayList<String>();// 三组
List<String> fourTeam = new ArrayList<String>();// 四组
List<String> fiveTeam = new ArrayList<String>();// 五组
List<String> sixTeam = new ArrayList<String>();// 六组
List<String> sevenTeam = new ArrayList<String>();// 七组
List<String> eightTeam = new ArrayList<String>();// 八组

for (int i = 0; i < student.size(); i++) {
// 分配小组
String peploe = student.get(i);
int mod = i % 8;
if (mod == 0) {
oneTeam.add(peploe);
} else if (mod == 1) {
twoTeam.add(peploe);
} else if (mod == 2) {
threeTeam.add(peploe);
} else if (mod == 3) {
fourTeam.add(peploe);
} else if (mod == 4) {
fiveTeam.add(peploe);
} else if (mod == 5) {
sixTeam.add(peploe);
} else if (mod == 6) {
sevenTeam.add(peploe);
} else if (mod == 7) {
eightTeam.add(peploe);
}
}

// 小组随机分配
System.out.println(“一组:” + oneTeam + “组长默认:” + oneTeam.get(1));
System.out.println(“二组:” + twoTeam + “组长默认:” + twoTeam.get(3));
System.out.println(“三组:” + threeTeam + “组长默认:” + threeTeam.get(3));
System.out.println(“四组:” + fourTeam + “组长默认:” + fourTeam.get(2));
System.out.println(“五组:” + fiveTeam + “组长默认:” + fiveTeam.get(2));
System.out.println(“六组:” + sixTeam + “组长默认:” + sixTeam.get(1));
System.out.println(“七组:” + sevenTeam + “组长默认:” + sevenTeam.get(3));
System.out.println(“八组:” + eightTeam + “组长默认:” + eightTeam.get(3));
System.out.println(“九组:” + one + “组长默认:” + one);

}

}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848