| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 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 | 31 | 
                                        Tags
                                        
                                    
                                        
                                    - codesingal
- Counting cells in a blob
- til
- centuryFromYear
- 피보나치 수
- Daily Commit
- adjacentElementsProduct
- Numpy
- 파이썬머신러닝완벽가이드
- 수 정렬하기
- 파이썬 포렌식
- data_structure
- almostIncreasingSequence
- 2015 봄학기 알고리즘
- cpp
- markdown
- C++
- Sequential Search
- Python
- flask
- shapeArea
- recursion
- matrixElementsSum
- 10953
- All Longest Strings
- collections.deque
- codesignal
- 백준
- baekjun
- 2750
                                        Archives
                                        
                                    
                                        
                                    - Today
- Total
Introfor
[백준] 2750, 2751, 10989번 / 수 정렬하기1, 2, 3 본문
sort 알고리즘을 공부하면서 알게된 내용을 활용해서 풀었다.
[2750, 2751번] 수 정렬하기1, 2
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n = 0;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	vector<pair<int, int>> v(n);
    
	for (int i=0; i<n; i++){
		cin >> v[i].first;
		v[i].second = i;
	}
    
	sort(v.begin(), v.end());
    
	for (int i = 0; i < n; i++)
		cout << v[i].first << '\n';
        
	return 0;
}[10989번] 수 정렬하기3
#include <iostream>
using namespace std;
int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int arr[10001]={0,};
	int n = 0;
	cin >> n;
	for(int i=0; i<n; i++){
		int tmp = 0;
		cin >> tmp;
		arr[tmp]++;
	}
	for(int i = 1 ; i <= 10000; i++)
		for (int j = 0; j < arr[i]; j++)
			cout << i << "\n";
	return 0;
}
//배열의 index를 활용하여 정렬vector, pair를 모를 경우 여기클릭
'Programming_prob > BaekJoon' 카테고리의 다른 글
| [백준] 9093번 stack (0) | 2020.09.09 | 
|---|---|
| [백준] 10953번 / A+B - 6 (0) | 2020.07.03 | 
| [백준] 10870번 / 피보나치 수 5 (0) | 2020.07.01 | 
| [백준] 10872번 / 팩토리얼 (0) | 2020.07.01 | 
| 1000번 (0) | 2019.07.05 | 
                          Comments