|
发表于 2019-3-18 10:57:51
|
显示全部楼层
本帖最后由 zjhahaha 于 2019-3-18 11:04 编辑
ll=[]
for i in range(1,5):
for j in range(1,5):
if i == j:
continue
else:
for k in range(1,5):
if i != k and i != j and j != k:
ls=[]
ls.append(i)
ls.append(j)
ls.append(k)
ll.append(tuple(ls))
#print(i,j,k)
print(len(ll))
for w in ll:
print(w)
​
24
(1, 2, 3)
(1, 2, 4)
(1, 3, 2)
(1, 3, 4)
(1, 4, 2)
(1, 4, 3)
(2, 1, 3)
(2, 1, 4)
(2, 3, 1)
(2, 3, 4)
(2, 4, 1)
(2, 4, 3)
(3, 1, 2)
(3, 1, 4)
(3, 2, 1)
(3, 2, 4)
(3, 4, 1)
(3, 4, 2)
(4, 1, 2)
(4, 1, 3)
(4, 2, 1)
(4, 2, 3)
(4, 3, 1)
(4, 3, 2)
​
ll=[]
for i in range(1,5):
for j in range(1,5):
#减少循环步骤
if i == j:
continue
else:
for k in range(1,5):
if i != k and i != j and j != k:
ls=[]
ls.append(i)
ls.append(j)
ls.append(k)
ll.append(tuple(ls))
#print(i,j,k)
print(“可组成的数量为{}”.format(len(ll)))
for w in ll:
print("组成:"+w)
File "<ipython-input-5-5f40a9f002fc>", line 17
print(“可组成的数量为{}”.format(len(ll)))
^
SyntaxError: invalid character in identifier
"
​
ll=[]
for i in range(1,5):
for j in range(1,5):
#减少循环步骤
if i == j:
continue
else:
for k in range(1,5):
if i != k and i != j and j != k:
ls=[]
ls.append(i)
ls.append(j)
ls.append(k)
ll.append(tuple(ls))
#print(i,j,k)
print("可组成的数量为{}.format(len(ll)))
for w in ll:
print("组成:"+w)
File "<ipython-input-6-d50335e9eabf>", line 17
print("可组成的数量为{}.format(len(ll)))
^
SyntaxError: EOL while scanning string literal
​
ll=[]
for i in range(1,5):
for j in range(1,5):
#减少循环步骤
if i == j:
continue
else:
for k in range(1,5):
if i != k and i != j and j != k:
ls=[]
ls.append(i)
ls.append(j)
ls.append(k)
ll.append(tuple(ls))
#print(i,j,k)
print("可组成的数量为{}.format(len(ll)))
for w in ll:
print("组成:"+w)
File "<ipython-input-7-d50335e9eabf>", line 17
print("可组成的数量为{}.format(len(ll)))
^
SyntaxError: EOL while scanning string literal
ll=[]
for i in range(1,5):
for j in range(1,5):
#减少循环步骤
if i == j:
continue
else:
for k in range(1,5):
if i != k and i != j and j != k:
ls=[]
ls.append(i)
ls.append(j)
ls.append(k)
ll.append(tuple(ls))
#print(i,j,k)
print("可组成的数量为{}".format(len(ll)))
for w in ll:
print("组成:{}".format(w))
可组成的数量为24
组成:(1, 2, 3)
组成:(1, 2, 4)
组成:(1, 3, 2)
组成:(1, 3, 4)
组成:(1, 4, 2)
组成:(1, 4, 3)
组成:(2, 1, 3)
组成:(2, 1, 4)
组成:(2, 3, 1)
组成:(2, 3, 4)
组成:(2, 4, 1)
组成:(2, 4, 3)
组成:(3, 1, 2)
组成:(3, 1, 4)
组成:(3, 2, 1)
组成:(3, 2, 4)
组成:(3, 4, 1)
组成:(3, 4, 2)
组成:(4, 1, 2)
组成:(4, 1, 3)
组成:(4, 2, 1)
组成:(4, 2, 3)
组成:(4, 3, 1)
组成:(4, 3, 2) |
|