北邮 找最小数 Easy

基本思想:

无;

关键点:

无;

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

struct node {
	int x;
	int y;
};

node num[1010];

bool cmp(node a, node b) {
	if (a.x == b.x)
		return a.y < b.y;
	else {
		return a.x < b.x;
	}
}

int main() {
	int n;
	while (cin >> n) {
		for (int i = 0; i < n; i++) {
			cin >> num[i].x >> num[i].y;
		}
		sort(num, num + n, cmp);
		cout << num[0].x << " " << num[0].y << endl;
	}
}

  

猜你喜欢

转载自www.cnblogs.com/songlinxuan/p/12458040.html