Réponse :
Explications :
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
B = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
for j in range(3):
B[i][j] = A[j][i]
print("B = ", B)
L = [[2, 7], [4, 1], [5, 1], [3, 5], [1, 11], [2, 4]]
def triDecroissant(list):
for i in range(len(list)):
for j in range(i + 1, len(list)):
if list[i][0] < list[j][0]:
VarTemp = list[i]
list[i] = list[j]
list[j] = VarTemp
return list
print("triDecrossant de L = ", triDecroissant(L))
Python console
B = [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
triDecrossant de L = [[5, 1], [4, 1], [3, 5], [2, 7], [2, 4], [1, 11]]
Copyright © 2024 ELIBRARY.TIPS - All rights reserved.
Lista de comentários
Réponse :
Explications :
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
B = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
for j in range(3):
B[i][j] = A[j][i]
print("B = ", B)
ce bout de programme retourne :
B = [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
L = [[2, 7], [4, 1], [5, 1], [3, 5], [1, 11], [2, 4]]
def triDecroissant(list):
for i in range(len(list)):
for j in range(i + 1, len(list)):
if list[i][0] < list[j][0]:
VarTemp = list[i]
list[i] = list[j]
list[j] = VarTemp
return list
print("triDecrossant de L = ", triDecroissant(L))
Python console
B = [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
triDecrossant de L = [[5, 1], [4, 1], [3, 5], [2, 7], [2, 4], [1, 11]]