Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 우선순위큐
- 분할정복
- 알고리즘
- 최소공배수
- vector
- priority_queue
- Set
- C++
- 프로그래머스
- DP
- 유클리드호제법
- 백준
- 티스토리챌린지
- 백트래킹
- 그래프
- N과M
- 배열
- 에라토스테네스의 체
- map
- int
- 이분탐색
- stoi
- BFS
- Sort
- 다이나믹프로그래밍
- 오블완
- 문자열
- DFS
- 깊이우선탐색
- 정렬
Archives
- Today
- Total
안녕 세상아,
[백준/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 나이순 정렬 (0) | 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 |