题解 | #找最小数#
找最小数
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);
}
}
查看23道真题和解析
联想公司福利 1500人发布