博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
蛇形填数(算法竞赛入门经典)
阅读量:4619 次
发布时间:2019-06-09

本文共 610 字,大约阅读时间需要 2 分钟。

#include
#include
#include
#define max 20using namespace std;int a[max][max];int main(){ int x, y, n, tot = 0; cin >> n; memset(a, 0, sizeof(a)); tot = a[x = 0][y = n - 1] = 1; while (tot
= 0 && !a[x][y - 1]) a[x][--y] = ++tot; while (x - 1>=0 && !a[x - 1][y])a[--x][y] = ++tot; while (y + 1 < n&&!a[x][y + 1]) a[x][++y] = ++tot; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout << a[i][j] << " "; } cout << endl; } system("pause"); return 0;}

  

转载于:https://www.cnblogs.com/wujufengyun/p/6897245.html

你可能感兴趣的文章
create-react-app 配置sass
查看>>
02_关系数据库
查看>>
在win7电脑中如何查看运行进程的PID标识符
查看>>
[Vue] vue-cli3.0安装
查看>>
shell中如何进行算术运算
查看>>
为什么所有的架构都是糟糕的
查看>>
(十三)在ASP.NET CORE中使用Options
查看>>
解决Centos/Redhat,命令不存在
查看>>
项目实战—小饭桌
查看>>
2012考研英语--前辈的高分复习经验
查看>>
UVA10603倒水问题+隐式图搜索
查看>>
C++学习之字符串
查看>>
图像化列表
查看>>
2014年10月9日——语言基础2
查看>>
mysql查
查看>>
[正则表达式]难点和误区
查看>>
217. Contains Duplicate
查看>>
hadoop遇到问题总结
查看>>
Windows下手动安装redis服务
查看>>
把 MongoDB 当成是纯内存数据库来使用(Redis 风格)
查看>>