题目传送门

#include <bits/stdc++.h>

using namespace std;

const int N = 1100;
struct Student {
    string name;
    int x;
    int y;
    int z;
    int sum;
} a[N];
int n;

void check(Student p, Student q) {
    if (abs(p.x - q.x) <= 5 && abs(p.y - q.y) <= 5 && abs(p.z - q.z) <= 5 &&
        abs(p.sum - q.sum) <= 10) {
        cout << p.name << " " << q.name << endl;
    }
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].name >> a[i].x >> a[i].y >> a[i].z;
        a[i].sum = a[i].x + a[i].y + a[i].z;
    }

    for (int i = 1; i < n; i++)
        for (int j = i + 1; j <= n; j++)
            check(a[i], a[j]);
    return 0;
}

相关文章:

  • 2022-02-10
  • 2021-11-28
  • 2021-07-12
  • 2021-11-28
  • 2022-02-07
  • 2021-09-15
  • 2021-10-07
  • 2022-12-23
猜你喜欢
  • 2021-05-18
  • 2021-11-28
  • 2022-01-16
  • 2022-12-23
  • 2021-12-31
  • 2021-11-11
相关资源
相似解决方案