能不能把下面的代码分行def set_zeroes(matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ row_zeroes = [] col_zeroes = [] for i in range(len(matrix)): for j in range(len(matrix[0])): if matrix[i][j] == 0: row_zeroes.append(i) col_zeroes.append(j) for row in row_zeroes: for j in range(len(matrix[0])): matrix[row][j] = 0 for col in col_zeroes: for i in range(len(matrix)): matrix[i][col] = 0
时间: 2023-06-05 07:08:22 浏览: 169
DFT的matlab源代码-sp800_22_tests:SP800-22Rev1aPRNG测试套件的python实现
可以,以下是分行的代码:
def set_zeroes(matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
row_zeroes = []
col_zeroes = []
for i in range(len(matrix)):
for j in range(len(matrix[0])):
if matrix[i][j] == 0:
row_zeroes.append(i)
col_zeroes.append(j)
for row in row_zeroes:
for j in range(len(matrix[0])):
matrix[row][j] = 0
for col in col_zeroes:
for i in range(len(matrix)):
matrix[i][col] = 0
阅读全文