奇数阶魔方 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4861 Accepted Submission(s): 2770 Problem Description 一个 n 阶方阵的元素是1,2,...,n^2,它的每行,每列和2条对角线上元素的和相等,这样的方阵叫魔方.n为奇数时我们有1种构造方法,叫做“右上方” ,例如下面给…
#include<stdio.h>#include <string.h>int main(){ int n,m; int a[40][40]={0}; scanf("%d",&n); while(n--) { scanf("%d",&m); int i; int j; memset(a,0,sizeof(a)); i=0; j=m/2; int k=1; while(k<=m*m) { if(i<0&&am…