题解 | #找最小数#
找最小数
https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd
#include<cstdio> #include<algorithm> using namespace std; struct zhengshu { int x; int y; }; bool comp(zhengshu lhs, zhengshu rhs) { if (lhs.x < rhs.x) { return true; } else if (lhs.x == rhs.x && lhs.y < rhs.y) { return true; } else { return false; } } int main() { int n; zhengshu arr[1000]; while (scanf("%d", &n) != EOF) { for (int i = 0 ; i < n ; ++ i) { scanf("%d%d\n", &arr[i].x, &arr[i].y); } sort(arr, arr + n, comp); printf("%d %d\n", arr[0].x, arr[0].y); } printf("\n"); }