首页 > 其他 > 详细

1082 射击比赛 (20 分)

时间:2019-04-30 01:07:10      阅读:202      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
struct s {
    string id;
    int dis;
} num[10010];   // 结构体数组变量开的大一点
bool cmp (s a, s b) {  // 形参中用结构体定义两个结构体变量
    return a.dis < b.dis;
}
int main() {
    int n, x, y;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> num[i].id >> x >> y;
        num[i].dis = x * x + y * y;    // 将其平方加入到结构体数组变量中
    }
    sort(num, num + n, cmp);   // 排序
    cout << num[0].id <<   << num[n - 1].id << endl;
    return 0;
}

 

1082 射击比赛 (20 分)

原文:https://www.cnblogs.com/Hk456/p/10793644.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!