题目传送门:
题解:
#include#include #include using namespace std;struct Infor { string num; int x; int y; float score;};void IniteInfor(Infor infor[], int n) { for (int i = 0; i < n; i++) { infor[i].num = ""; infor[i].x = 0; infor[i].y = 0; infor[i].score = 0.0; }}bool cmp(Infor infor1, Infor infor2) { return infor1.score > infor2.score;}int main() { int n; cin >> n; Infor infor[n]; IniteInfor(infor, n); for (int i = 0; i < n; i++) { cin >> infor[i].num >> infor[i].x >> infor[i].y; infor[i].score = sqrt(infor[i].x*infor[i].x + infor[i].y*infor[i].y); } sort(infor, infor + n, cmp); cout << infor[n - 1].num << " " << infor[0].num << endl; return 0;}