文章

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...

登录查看完整内容


登录后发布评论

1 条评论
彻底死去
2026年3月17日 22:02

一神神了

赞(1)
回复给: