社区讨论

全WA,求解答

B2100同行列对角线的格参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@mibh94v8
此快照首次捕获于
2025/11/23 16:49
3 个月前
此快照最后确认于
2025/11/23 17:46
3 个月前
查看原帖
CPP
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
    int n, i, j;
    cin >> n >> i >> j;
    for (int y = 1; y <= n; ++y) {
        cout << "(" << i << "," << y << ") ";
    }
    cout << endl;
    for (int x = 1; x <= n; ++x) {
        cout << "(" << x << "," << j << ") ";
    }
    cout << endl;
    for (int k = 0; k < n; ++k) {
        int x = i - j + k;
        int y = k + j - i;
        if (x >= 1 && x <= n && y >= 1 && y <= n) {
            cout << "(" << x << "," << y << ") ";
        }
    }
    cout << endl;
    for (int k = 0; k < n; ++k) {
        int x = i + j - 2 * k;
        int y = k + i + j - x;
        if (x >= 1 && x <= n && y >= 1 && y <= n) {
            cout << "(" << x << "," << y << ") ";
        }
    }
    return 0;
}

回复

2 条回复,欢迎继续交流。

正在加载回复...