题目
输出这样的三角形 1 2 3 4 5 12 13 14 6 11 15 7 10 8 9
1 2 3 4 5
12 13 14 6
11 15 7
10 8
9
1 2 3 4 5
12 13 14 6
11 15 7
10 8
9
提问时间:2021-09-11
答案
#include
using namespace std;
void print(int b)
{
int orientation = 0;
int** a = new int*[b+1];
for(int i = 0; i < b+1; i++)
{
a[i] = new int[b+1];
}
for(int i = 0; i < b+1; i++)
{
for(int j= 0; j < b+1; j++)
{
if(i+j < b)
{
a[i][j] = 0;
}
else
{
a[i][j] = -1;
}
}
}
a[0][0] = 1;
int x = 0;
int y = 0;
int num = (1+b)*b/2;
for(int i = 2; i = 1 && a[x-1][y+1] == 0)
{
x -= 1;
y += 1;
a[x][y] = i;
continue;
}
orientation = 2;
}
if(orientation == 2)
{
if(a[x][y-1] == 0)
{
y -= 1;
a[x][y] = i;
continue;
}
orientation = 0;
}
if(orientation == 0)
{
if(a[x+1][y] == 0)
{
x += 1;
a[x][y] = i;
continue;
}
orientation = 1;
}
}
for(int i = 0; i < b; i++)
{
for(int j = 0; j < b-i; j++)
{
cout
using namespace std;
void print(int b)
{
int orientation = 0;
int** a = new int*[b+1];
for(int i = 0; i < b+1; i++)
{
a[i] = new int[b+1];
}
for(int i = 0; i < b+1; i++)
{
for(int j= 0; j < b+1; j++)
{
if(i+j < b)
{
a[i][j] = 0;
}
else
{
a[i][j] = -1;
}
}
}
a[0][0] = 1;
int x = 0;
int y = 0;
int num = (1+b)*b/2;
for(int i = 2; i = 1 && a[x-1][y+1] == 0)
{
x -= 1;
y += 1;
a[x][y] = i;
continue;
}
orientation = 2;
}
if(orientation == 2)
{
if(a[x][y-1] == 0)
{
y -= 1;
a[x][y] = i;
continue;
}
orientation = 0;
}
if(orientation == 0)
{
if(a[x+1][y] == 0)
{
x += 1;
a[x][y] = i;
continue;
}
orientation = 1;
}
}
for(int i = 0; i < b; i++)
{
for(int j = 0; j < b-i; j++)
{
cout
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1As an athlete(运动员),Liu Xiang is _______ success.We are all proud _______him.
- 2It was as a physician that he represented himself,and ____ he was warmly received.A.as such B.
- 3(x+y/2)²-(x-y/2)²等于
- 4干预 用英语怎么说啊?急!
- 5某体育场的环行跑道长400米,甲、乙同时从同一起点分别以一定的速度练习长跑和骑自行车.如果反向而行,那么他们每隔30秒相遇一次.如果同向而行,那么每隔80秒乙就追上甲一次.甲、
- 6你知道我正在关注你吗用英语怎么说
- 7英语翻译
- 8英语好的同学们都来帮帮我吧.
- 9可采用哪些措施减少建筑物沉降和不均匀沉降?
- 10若a,b是方程2*x平方-5x-6=0的两个实根,求代数式2*a平方+7a+2b的值
热门考点
- 1原谅我问那么傻的问题...
- 2月夜忆舍弟 杜甫 戍鼓断人行,边秋一雁声. 露从今夜白,月是故乡明. 有弟皆分散,无家问死生.
- 3直线l经过抛物线y2=4x的焦点,且与抛物线相交于A,B两点,若弦AB中点的横坐标为3,则|AB|=_.
- 4合外力为零,内力中只有保守力的系统,机械能是否守恒
- 5老人与海中老人的形象
- 6已知集合A={x|x^2+2(a+1)x+a^2-1=0},B={x|x^2+4x=0},A交于B=A,求实数a的取值范围.
- 7七侓·长征
- 8已知m+n=10,mn=24求(1)m²+n²(2)(m-n)²
- 9一口袋装有带编号的7个白球和3个黑球,求从中摸出两球,先摸出黑球,后摸出白球的概率
- 10甲数比乙数多15%,乙数就比甲数少15%._.(判断对错)