text1
来源:互联网 发布:内网软件 编辑:程序博客网 时间:2024/06/05 04:01
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int a[50][50];
cout << "输入行数(需为奇数)" << endl;
int x;
int i,j;
cin >> x;
if(x % 2 == 0)
{
cout << "error" << endl;
return 0;
}
for(i = 0; i < x; i++)
{
for(j = 0; j < x; j++)
{
a[i][j] = 0;
}
}
i = 0;
j = x/2;
a[i][j] = 1;
int p,q;
for(int t = 2; t < x*x; t++)
{
//int p,q;
p = i;
q = j;
i--;
j++;
if(i < 0)
{
i = x - 1;
}
if(j >= x)
{
j = 0;
}
if(a[i][j] != 0)
{
i = p + 1;
j = q;
}
a[i][j] = t;
}
for(int i = 0; i < x; i++)
{
for(int j = 0; j < x; j++)
{
cout << setw(4) << a[i][j];
}
cout << endl;
}
return 0;
}
#include <iomanip>
using namespace std;
int main()
{
int a[50][50];
cout << "输入行数(需为奇数)" << endl;
int x;
int i,j;
cin >> x;
if(x % 2 == 0)
{
cout << "error" << endl;
return 0;
}
for(i = 0; i < x; i++)
{
for(j = 0; j < x; j++)
{
a[i][j] = 0;
}
}
i = 0;
j = x/2;
a[i][j] = 1;
int p,q;
for(int t = 2; t < x*x; t++)
{
//int p,q;
p = i;
q = j;
i--;
j++;
if(i < 0)
{
i = x - 1;
}
if(j >= x)
{
j = 0;
}
if(a[i][j] != 0)
{
i = p + 1;
j = q;
}
a[i][j] = t;
}
for(int i = 0; i < x; i++)
{
for(int j = 0; j < x; j++)
{
cout << setw(4) << a[i][j];
}
cout << endl;
}
return 0;
}
阅读全文
0 0
- text1
- text1
- text1
- text1
- text1
- text1.cpp
- text1+text2=text3
- Java之数组text1
- text1 + text2 =text3
- 考研英语阅读-text1
- 关于android.R.id.text1
- OJ text1 A+B Problem
- undefined reference to `vtable for TEXT1'
- ArrayAdapter中的android.R.id.text1是什么
- zzuli蓝桥 text1 D find sum
- zzuli蓝桥 text1 F 木块拼接
- zzuli蓝桥 text1 G 搬砖
- zzuli蓝桥 text1 I 平方和
- SSM框架原理,作用及使用方法
- 如何测试报表的查询条件
- C++ 中通过GetAdaptersInfo获取网卡配置和Ip地址信息
- 总结反思-贪吃蛇的移动
- 雅虎前端优化35条军规
- text1
- vue.js-window系统的环境搭建
- 如何使用shell脚本快速排序和去重文件数据
- zookeeper-3
- 利用注解实现spring基本配置详解
- 工作流学习——Activiti流程变量五步曲
- mysql 批量循环插入数据
- PHPStorm基本的配置配置
- java分布式系统开关功能设计(服务升降级)