这题就是一个sb题,本来很水,硬是说得很含混。奇数阶幻方构造其实有好多方法,这题既不special judge,也不说清楚,以为这样能把水题变成难题似的,简直想骂出题人。

/*
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;
const int MAXN = ;
int data[MAXN][MAXN]; int main() {
int T, n;
scanf("%d", &T);
for (int t = ; t <= T; t++) {
scanf("%d", &n);
memset(data, , sizeof(data));
int i = , j = n / ;
data[i][j] = ;
for (int k = ; k <= n * n; k++) {
int x = (i - + n) % n;
int y = (j + ) % n;
if (data[x][y] > ) {
y = j;
x = (i + ) % n;
}
data[x][y] = k;
i = x;
j = y;
}
for (i = ; i < n; i++) {
for (j = ; j < n; j++) {
printf("%4d", data[i][j]);
}
putchar('\n');
}
}
return ;
}

最新文章

  1. C标准头文件&lt;ctype.h&gt;
  2. CR LF的由来
  3. C/C++实践笔记 003
  4. CAD系统变量(参数)大全
  5. linux性能监控基础命令
  6. Centos下使用gitosis配置管理git服务端(转载)
  7. C# DES 加密 解密
  8. 如何显示Mac OS X上的隐藏文件和文件夹
  9. Mysql复制一个数据库到另一个数据库
  10. select 两层 第二个select需要加别名
  11. 原生JS-旋转木马
  12. 【回顾】html简介、基础、元素
  13. 【20171123】【GITC精华演讲】贝业新兄弟李济宏:如何做到企业信息化建设的加减乘除
  14. 遗留系统:IT攻城狮永远的痛
  15. 爬虫框架Scrapy之案例三图片下载器
  16. Sersync + Rsync 代码分发
  17. 在Sqlserver中生成随机数据
  18. C#定时任务的偷懒实现
  19. 【CodeForces】841D. Leha and another game about graph(Codeforces Round #429 (Div. 2))
  20. Java任务调度框架----kunka

热门文章

  1. SDUT1586 计算组合数(组合数)
  2. VisualSvn+TortoiseSVN的安装说明
  3. ccflow学习下载网址
  4. http://www.aboutyun.com/thread-8792-1-1.html
  5. 李洪强漫谈iOS开发[C语言-009] - C语言关键字
  6. lintcode :Permutation Index 排列序号
  7. java socket知识点
  8. Eclipse:快捷
  9. liunx下tomcat启动报错
  10. tomcat 内存配置