You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package cap3
|
|
|
|
|
|
|
|
func Work15() map[string]string {
|
|
|
|
// 甲队成员
|
|
|
|
teamA := []string{"A", "B", "C"}
|
|
|
|
|
|
|
|
// 乙队成员
|
|
|
|
teamB := []string{"X", "Y", "Z"}
|
|
|
|
|
|
|
|
match := map[string]string{}
|
|
|
|
|
|
|
|
// 遍历所有可能的匹配方式
|
|
|
|
for _, b := range teamB {
|
|
|
|
for _, a := range teamA {
|
|
|
|
// A不和X比赛
|
|
|
|
if a == "A" && b == "X" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// C不和X或Z比赛
|
|
|
|
if a == "C" && (b == "X" || b == "Z") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// 如果没人匹配,当前就作为对手匹配
|
|
|
|
if _, exists := match[b]; !exists {
|
|
|
|
match[a] = b
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return match
|
|
|
|
}
|