import java.util.HashMap;
import java.util.Map;
/**
* 乒乓球队比赛,甲队有abc三人,乙队有xyz三人。
* 抽签得出比赛名单:a不和x比,c不和x,z比,
* 利用集合求出比赛名单
* @author 努力coding
* @version
* @data 2020年2月
*/
public class FindTeam {
public static void main(String[] args) {
Map<Character,Character> stu = new HashMap<Character,Character>();
/**假设a对x,b对y,c对z*/
char a = 'x';
char b = 'y';
char c = 'z';
char temp;//临时变量
//c不和x,z比
for(temp = 'x'; temp <= 'z'; temp++) {
if(temp != 'x' && temp != 'z') {
c = temp;
stu.put('c', c);//存入Map中
}
}
//a不和x比
for(temp = 'x'; temp <= 'z'; temp++) {
if(temp != 'x' && temp != c) {
a = temp;
stu.put('a', a);
}
}
//a和c的对手都已知,剩下的就是b的对手
for(temp = 'x'; temp <= 'z'; temp++) {
if(temp != a && temp != c) {
b = temp;
stu.put('b', b);
}
}
System.out.println("比赛名单如下:");
for(char key : stu.keySet()) {
System.out.println(key + " VS " + stu.get(key));
}
}
}