文章
133
粉丝
17
获赞
400
访问
10.9k
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main() {
int n;
cin >> n;
int top = 0, bottom = n - 1, left = 0, right = n - 1, arr[20][20], num = 1;
while (top <= bottom && left <= right) {
for (int i = top;i <= bottom;i++) {
arr[i][left] = num++;
}
left++;
for (int i = left;i <= right;i++) {
arr[bottom][i] = num++;
}
bottom--;
for (int i = bottom;i >= top;i--) {
arr[i][right] = num++;
}
right--;
&nb...
登录后发布评论
一神神了