题解 | #找最小数#
找最小数
https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd
#include <stdio.h> typedef struct { int x; int y; } Data; int main() { int n; while ((scanf("%d", &n)) != EOF) { int m = n; int p = n; Data D[n]; for (int i = 0; i < n; i++) { scanf("%d %d", &D[i].x, &D[i].y); } while (n--) { for (int j = 0; j < n; j++) { if (D[j].y > D[j + 1].y) { Data T = D[j]; D[j] = D[j + 1]; D[j + 1] = T; } } } while (m--) { for (int k = 0; k < m; k++) { if (D[k].x > D[k + 1].x) { Data T = D[k]; D[k] = D[k + 1]; D[k + 1] = T; } } } printf("%d %d\n", D[0].x, D[0].y); } return 0; }