代码如下,望采纳
def get_worker(matrix):
while True:
for i in range(4):
if matrix[i].count(2) == 1:
for j in range(4):
if matrix[i][j] == 2:
matrix[i][j] = 1
else:
matrix[i][j] = 0
for j in range(4):
if [matrix[i][j] for i in range(4)].count(2) == 1:
for i in range(4):
if matrix[i][j] == 2:
matrix[i][j] = 1
else:
matrix[i][j] = 0
if matrix[1][2] == 1:
return "乙"
elif matrix[2][1] == 1:
return "甲"
elif matrix[3][1] == 1:
return "丁"
elif matrix[0][3] == 1:
return "丙"
matrix = [[2, 0, 0, 0], [0, 2, 1, 0], [0, 0, 2, 1], [1, 0, 0, 2]]
print(get_worker(matrix))