1 条题解

  • 0
    @ 2024-10-16 20:21:35

    参考答案:

    #include<iostream>
    #include<algorithm>
    using namespace std;
    const int N = 20;
    struct node
    {
        long long a;
        long long b;
        long long c;
    };
    bool cmp(struct node a1, struct node b1)
    {
        return a1.c < b1.c;
    }
    int main()
    {
        int n;
        cin >> n;
        struct node a[N];
        for (int i = 1; i <= n; ++i)
        {
            cin >> a[i].a >> a[i].b;
            a[i].c = a[i].a * a[i].a + a[i].b * a[i].b;
        }
        sort(a + 1, a + 1 + n, cmp);
        for (int i = 1; i <= n; ++i)
        {
            cout << a[i].a << ' ' << a[i].b << ' ' << a[i].c << endl;
        }
    
        return 0;
    }
    
    • 1

    信息

    ID
    5417
    时间
    1000ms
    内存
    256MiB
    难度
    1
    标签
    递交数
    2
    已通过
    1
    上传者