Foreword:
21. Regardless of whether you can enter the retest or not, record the garbage code written on the road. I originally gnawed on "Algorithm Notes", but I felt too much to do it, so I changed it to the Kingway Computer Test Guide.
Title description:
Enter a number n in the first line, 1 <= n <= 1000, enter n lines of data below, each line has two numbers, xy respectively. Output a set of xy, the set of data is the smallest x among all the data, and the smallest y when x is equal.
Enter description
There are multiple sets of data entered.
Enter n for each group, and then enter n integer pairs.
Output description:
Output the smallest integer pair.
answer
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;
struct num {
int x;
int y;
};
bool cmp(num a, num b) {
if (a.x != b.x)
return a.x < b.x;
else
return a.y < b.y;
}
int main()
{
int n;
num temp;
while (scanf("%d", &n) != EOF) {
vector<num> vi;
for (int i = 0; i < n; i++) {
cin >> temp.x >> temp.y;
vi.push_back(temp);
}
sort(vi.begin(), vi.end() , cmp);
printf("%d %d\n", vi[0].x, vi[0].y);
}
return 0;
}