北航机试题-找最小数

在这里插入图片描述
在这里插入图片描述
送分题,要拿好。

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1005;
struct Data{
	int x;
	int y;
};
Data buf[maxn];
bool cmp(Data a,Data b){
	if(a.x!=b.x)  return a.x<b.x;
	else return a.y<b.y;
}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		for(int i=0;i<n;i++){
			scanf("%d %d",&buf[i].x,&buf[i].y);
		}
		sort(buf,buf+n,cmp);
		printf("%d %d\n",buf[0].x,buf[0].y);
	}
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/weixin_37762592/article/details/88726013