题解 | #找最小数#

找最小数

https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX=1000;

struct Numbers{
    int x;
    int y;
};

Numbers arr[MAX];

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

int main() {
    int n;
    while(scanf("%d",&n)!=EOF){
        for(int i=0;i<n;i++){
            cin>>arr[i].x>>arr[i].y;
        }
        sort(arr,arr+n,Compare);
        cout<<arr[0].x<<" "<<arr[0].y<<endl;
    }
    return 0;;
}
// 64 位输出请用 printf("%lld")

考研复试机试 文章被收录于专栏

考研复试机试

全部评论

相关推荐

陆续:不可思议 竟然没那就话 那就我来吧 :你是我在牛客见到的最美的女孩
点赞 评论 收藏
分享
点赞 评论 收藏
分享
06-27 15:15
长安大学 Java
哈哈哈,你是老六:这种就是培训机构骗钱的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务