算法原理请参考:https://www.zhihu.com/question/23531676 先定义一些通用的函数,比如创建空幻方,删除幻方,打印幻方. 创建幻方 int **NewMagicS(int n) { int **magic = new int*[n]; for (int k = 0; k < n; k++) magic[k] = new int[n]; return magic; } 删除幻方 void DeleteMagicS(int **magic, int n) { for…
C. Magic Odd Square time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd.…
Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. Input The only line contains odd integer n (1 ≤ n ≤ 49). Output Print n lines with n integers. All the integers should be differ…