#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[100][100];
int x = 0, y = 0;
int dir = 0;
/dir == 1 右上方向
dir == -1 左下方向
dir == 0 无方向/
for (int i = 1; i < 10000; i++) {
if (x == 100 || y == 100)break;
arr[x][y] = i;
cout << x << "," << y << " " << "dir:" << dir <<"value:" <<i<< endl;
if (dir == -1) {
if (x == 0) {
++y;
dir = 1;
}
else {
--x;
++y;
}
}
else if (dir == 1) {
if (y == 0) {
++x;
dir = -1;
}
else {
++x;
--y;
}
}
else {
++x;
dir = -1;
}
}
cout << arr[19][19];
return 0;
```
}
using namespace std;
int main() {
int arr[100][100];
int x = 0, y = 0;
int dir = 0;
/dir == 1 右上方向
dir == -1 左下方向
dir == 0 无方向/
for (int i = 1; i < 10000; i++) {
if (x == 100 || y == 100)break;
arr[x][y] = i;
cout << x << "," << y << " " << "dir:" << dir <<"value:" <<i<< endl;
if (dir == -1) {
if (x == 0) {
++y;
dir = 1;
}
else {
--x;
++y;
}
}
else if (dir == 1) {
if (y == 0) {
++x;
dir = -1;
}
else {
++x;
--y;
}
}
else {
++x;
dir = -1;
}
}
cout << arr[19][19];
return 0;
```
}
0 回复
0 转发
0 喜欢
8 阅读



