文章

14

粉丝

130

获赞

0

访问

1.1k

头像
找最小数 题解:结构体+sort()
P1374 北京邮电大学机试题
发布于2024年4月26日 22:17
阅读数 68

#include<bits/stdc++.h>
using namespace std;

struct node{
    int x,y;
}p[100];

bool compare(node a,node b){
    if(a.x==b.x)
        return a.y<b.y;
    else
        return a.x<b.x;
}

int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>p[i].x>>p[i].y;
    sort(p+1,p+1+n,compare);
    cout<<p[1].x<<" "<<p[1].y<<endl;


    return 0;
}
 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发