n = int(input()) # 创建一个 n x n 的矩阵,初始化为 0 matrix = [[0] * n for _ in range(n)] count = 1 # 当前填充的数字 top, bottom, left, right = 0, n-1, 0, n-1 # 初始边界 while count <= n * n: # 从左到右填充上边界 for i in range(left, right + 1): matrix[top][i] = count count += 1 top += 1 # 从上到下填充右边界 for i in range(top, bottom +...