Notice
Recent Posts
Recent Comments
Link
안녕 세상아,
[백준/c++] 좌표 정렬하기 본문
https://www.acmicpc.net/problem/11650
vector<pair> 를 사용해서 값 받은 후 정렬해서 출력하면 된다.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
vector<pair<double,double>> v;
for (int i = 0; i < n; i++) {
int a, b;
cin >> a >> b;
v.push_back({ a,b });
}
sort(v.begin(), v.end());
for (int i = 0; i < n; i++) {
cout << v[i].first << " " << v[i].second << '\n';
}
}'백준' 카테고리의 다른 글
| [백준/c++] 10814 나이순 정렬 (1) | 2025.01.06 |
|---|---|
| [백준/c++] 분수 찾기 (0) | 2025.01.02 |
| [백준/c++] 4673 셀프 넘버 (1) | 2024.12.28 |
| [백준/c++] 2941 크로아티아 알파벳 (0) | 2024.12.28 |
| [백준/c++] 2751 수 정렬하기 2 (0) | 2024.12.27 |