C++???ξ?????????
???????????? ???????[ 2016/1/6 10:09:37 ] ??????????????????? .NET
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main(void) {
int n;
while(cin >> n) {
map<int?? map<int ?? int> > tbl;
for(int i = 0; i < n; ++i)
for(int j = 0; j < n; ++j)
tbl[i][j] = 0;
int cnt = 1;
int cir = 0;
while(true) {
if(tbl[cir][cir] != 0)
break;
int siz = n - cir*2;
for(int i = 0; i < siz - 1; ++i)
tbl[i + cir][cir] = cnt++;
for(int j = 0; j < siz - 1; ++j)
tbl[cir + siz - 1][cir + j] = cnt++;
for(int i = siz - 1; i > 0; --i)
tbl[cir + i][cir + siz - 1] = cnt++;
for(int j = siz - 1; j > 0; --j)
tbl[cir][cir + j] = cnt++;
if(tbl[cir][cir] == 0)
tbl[cir][cir] = cnt++;
++cir;
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) {
cout << setw(4) << tbl[i][j];
}
cout << endl;
}
}
return 0;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11