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

pair<int, int> p[100001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n = 0;
	cin >> n;

	for (int i = 0; i < n; ++i)
		cin >> p[i].first >> p[i].second;
	
	sort(p, p + n,
		[](pair<int, int> a, pair<int, int> b) {
			if (a.first == b.first)
				return a.second < b.second;
			else return a.first < b.first;
		});

	for (int i = 0; i < n; ++i)
		cout << p[i].first << " " << p[i].second << "\n";

	return 0;
}

endl말고 "\n"쓰자..............

 

https://www.acmicpc.net/problem/11650

 

11650번: 좌표 정렬하기

첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. (-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, 위치가 같은 두 점은 없다.

www.acmicpc.net