提交时间:2024-08-19 22:09:16

运行 ID: 168061

#include <iostream> using namespace std; struct Node { int x, y; }; bool cmp(Node a, Node b) { if (a.x == b.x) return a.y < b.y; return a.x < b.x; } int main() { int n; cin >> n; Node arr[100005]; for (int i = 1; i <= n; i++) { cin >> arr[i].x >> arr[i].y; } sort(arr + 1, arr + n + 1, cmp); for (int i = 1; i <= n; i++) { cout << arr[i].x << " " << arr[i].y << "\n"; } return 0; }