m = [[1,2,3],
[2,1,3],
[5,4,3]]
for i in range(len(m)):
for j in range(len(m)*len(m)):
if i <= len(m) and j <= (len(m)*len(m)):
m[i][j] <= m[i+1][j+1]
is_sink = "True"
if i <= (len(m)-1) and j <= (len(m)*len(m)):
m[i][j] <= m[i+1][j]
is_sink = "True"
if i <= len(m) and j <= ((len(m)*len(m))-1):
m[i][j] <= m[i][j+1]
is_sink = "True"
if i <= (len(m)-1) and j <= (len(m)*len(m)):
m[i][j] <= m[i+1][j-1]
is_sink = "True"
if i <= len(m) and j <= (len(m)*len(m)):
m[i][j] <= m[i-1][j+1]
is_sink = "True"
if i <= len(m) and j <= (len(m)*len(m)):
m[i][j] <= m[i][j-1]
is_sink = "True"
if i <= len(m) and j <= (len(m)*len(m)):
m[i][j] <= m[i-1][j]
is_sink = "True"
else:
is_sink = "False"
我试图比较相邻的单元格以显示地图上的最低点。虽然它显示超出范围,但我不太确定如何正确表达范围。我确信这段代码可以减少,但这是我目前可以显示的最佳长度。
相关分类