import
itertools
for
i
in
itertools.permutations(
'xyz'
):
if
i[
0
] !
=
'x'
and
i[
2
] !
=
'x'
and
i[
2
] !
=
'z'
:
print
(
'a vs %s, b vs %s, c vs %s'
%
(i[
0
], i[
1
], i[
2
]))
首页 > 技术文章 > 【Python3练习题 017】 两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比,c说他不和x,z比。请编程序找出三队赛手的名单。
jackzz 2018-06-02 14:47 原文
import
itertools
for
i
in
itertools.permutations(
'xyz'
):
if
i[
0
] !
=
'x'
and
i[
2
] !
=
'x'
and
i[
2
] !
=
'z'
:
print
(
'a vs %s, b vs %s, c vs %s'
%
(i[
0
], i[
1
], i[
2
]))