题解 | #找最小数#

找最小数

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

#include <stdio.h>
#include <stdlib.h>
typedef struct nums{
    int x;
    int y;
}NUMS;
int cmp(const void*a,const void*b){
    if(((NUMS *)a)->x == ((NUMS *)b)->x){
        return ((NUMS *)a)->y > ((NUMS *)b)->y;
    }
    return ((NUMS *)a)->x > ((NUMS *)b)->x;
}
int main() {
    int n;
    while (scanf("%d", &n) != EOF) { // 注意 while 处理多个 case
        NUMS arr[n];
        for(int i=0;i<n;++i){
            scanf("%d %d",&arr[i].x, &arr[i].y);
        }
        qsort(arr,n,sizeof(NUMS),cmp);
        printf("%d %d",arr[0].x,arr[0].y);
    }
    return 0;
}

全部评论

相关推荐

SHC2:关键问题是你这三段实习是三个不同的岗位…你这样子秋招就是只有一段实习的本科生..
点赞 评论 收藏
分享
哥_留个offer先:跟他说,你这个最好用c#,微软就用c#Java不适合这个项目
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务