无注释
2025-04-13 21:39:35
发布于:贵州
11阅读
0回复
0点赞
哲格镇德事NOIP思密达??
祝大家AKIOI
#include <bits/stdc++.h>
using namespace std;
void c(int n) {
vector<vector<int>> m(n, vector<int>(n, 0));
int row = 0, col = n / 2;
for (int k = 1; k <= n * n; ++k) {
m[row][col] = k;
int nextRow = (row - 1 + n) % n;
int nextCol = (col + 1) % n;
if (m[nextRow][nextCol] != 0) {
row = (row + 1) % n;
} else {
row = nextRow;
col = nextCol;
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
cout << m[i][j] << " ";
}
cout << endl;
}
}
int main() {
int n;
cin >> n;
c(n);
return 0;
}
全部评论 2
66
2025-04-13 来自 贵州
0666往年NOIP有点小水
2025-04-13 来自 贵州
0
有帮助,赞一个