两个乒乓球队进行比赛,各出3人。甲队为A、B、C3人,乙队为X、Y、Z3人。已抽签决定比赛名单。有人向队友打听比赛的名单。A说他不和X比,C说他不和X、Y比。请编程求出3对赛手的名单。

it2025-10-20  6

stu1=[“x”,“y”,“z”] b=[“x”,“y”,“z”] fa=[“x”] fc=[“x”,“z”] ta=[] tb=[] tc=[] for i in range (len (stu1)): if stu1[i] not in fa: h=stu1[i] ta.append(h) for i in range (len (stu1)): if stu1[i] not in fc: g=stu1[i] tc.append(g) for i in range(len(stu1)): for j in range (len (stu1)): if stu1[i] in ta and stu1[j] in tc and \ stu1[i]!=stu1[j]: a=stu1[i] c=stu1[j] b.remove(a) b.remove© b= ‘’ .join(b) print(“a的比赛对象是:”,a) print(“b的比赛对象是:”,b) print(“c的比赛对象是:”,c)

最新回复(0)