Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
78404 | 彭士宝 | 方阵填数 | Python3 | Accepted | 35 MS | 3808 KB | 430 | 2024-06-19 22:07:17 |
n = int(input()) #x,y =0 ,n-1 x, y = 0, n - 1 a = [[0] * n for _ in range(n)] i = 1 dirs = [(1, 0), (0, -1), (-1, 0), (0, 1)] a[x][y] = i while i < n**2: for d in dirs: x, y = x + d[0], y + d[1] while 0 <= x < n and 0 <= y < n and a[x][y] == 0: i += 1 a[x][y] = i x, y = x + d[0], y + d[1] x, y = x - d[0], y - d[1] for row in a: print(*row)