Run ID:140540
提交时间:2025-12-15 21:07:18
mines = [ "???**", "????*", "??**?", "???*?" ] rows = len(mines) cols = len(mines[0]) b = [[0 for _ in range(cols)] for _ in range(rows)] for i in range(rows): for j in range(cols): if mines[i][j] == "*": b[i][j] = "*" else: count = 0 if i-1 >= 0 and j-1 >= 0 and mines[i-1][j-1] == "*": count += 1 if i-1 >= 0 and mines[i-1][j] == "*": count += 1 if i-1 >= 0 and j+1 < cols and mines[i-1][j+1] == "*": count += 1 if j-1 >= 0 and mines[i][j-1] == "*": count += 1 if j+1 < cols and mines[i][j+1] == "*": count += 1 if i+1 < rows and j-1 >= 0 and mines[i+1][j-1] == "*": count += 1 if i+1 < rows and mines[i+1][j] == "*": count += 1 if i+1 < rows and j+1 < cols and mines[i+1][j+1] == "*": count += 1 b[i][j] = count print("最终扫雷结果:") for row in b: print("".join(str(x) for x in row))