第一题 8个区域对称
def print_martix(n): out_martix = [[0]*n for i in range(n)] m = n // 2 for i in range(0, m): for j in range(i + 1, m): out_martix[i][j] = 2 out_martix[j][i] = 3 out_martix[n-1-j][i] = 4 out_martix[n-1-i][j] = 5 out_martix[i][n-1-j] = 1 out_martix[j][n-1-i] = 8 out_martix[n-1-j][n-1-i] = 7 out_martix[n-1-i][n-1-j] = 6 return out_martix if __name__ == "__main__": n = int(input()) ma = print_martix(n) for i in range(n): print(' '.join(list(map(str,ma[i]))))
全部评论
(2) 回帖