当前位置: > 输出这样的三角形 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
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.