题解 | #找最小数#

找最小数

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

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

struct xy{
    int x;
    int y;
};

bool Comp(xy a, xy b){
    if (a.x > b.x) {
        return false;
    }else if(a.x == b.x && a.y > b.y){
        return false;
    }else {
        return true;
    }
};

int main() {
    int n;
    xy a[1000];
    while (scanf("%d",&n) != EOF) {
        for (int i= 0; i < n; ++i) {
            scanf("%d %d",&a[i].x,&a[i].y);
        }
        sort(a, a+n,Comp);
        printf("%d %d",a[0].x,a[0].y);
    }
}

全部评论

相关推荐

06-16 15:04
黑龙江大学 Java
零OFFER战士:另一个版本查看图片
点赞 评论 收藏
分享
见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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