题解 | #找最小数#

找最小数

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

#include <iostream>
using namespace std;
#include<cstdio>
#include<algorithm>
struct two{
    int x;
    int y;
};
two arr[1000];
bool compare(two p,two q){
    if(p.x==q.x)  return (p.y<q.y);
else return p.x<q.x;

}
int main() {
    int n, b;
    while (cin >> n) { // 注意 while 处理多个 case
      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;

}}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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