#include<array>
using namespace std;
int main() {
int input;
int next = 1, x, y, z;
x = y = 1;
z = 1;
cin >> input;
array<array<int, 101>, 101> point;
//point[1][1] = 0;
bool flag = true;
while (flag) {
point[x][y] = next;
if (y == z) {
y = 1; z++;
}
else {
x--, y++;
}
if (z > input) {
flag = false;
continue;
}
next++;
}
for (int i = 1; i <= input; i++)
for (int j = 1; j <= input; j++) {
if (point[i][j] != 0) {
cout << point[i][j];
if (j != input) {
cout << ' ';
}
}
}
return 0;
}
這個有bug,妳先看看,等我想通了我在補充