| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 구축
- hustoj
- STL
- SW역량테스트
- SWEA
- 백준
- 알고리즘
- 7576
- 온라인저지시스템구축
- oj
- 저지시스템구축
- 모의 SW 역량테스트
- 역량테스트
- IOS
- 비트마스킹
- 소스코드
- a형
- BOJ
- oj구축
- 개발
- 삼성기출
- 풀이
- 역테
- 삼성
- 온라인 저지 구축
- SWIFT
- xcode
- c++
- 모의 SW역량테스트
- SW Expert Academy
Archives
- Today
- Total
꾸르꾸르
[C++/STL] prev_permutation, next_permutation 순열찾기 본문
코딩, 알고리즘, 문제풀이/문법,알고리즘,C++,기타등등
[C++/STL] prev_permutation, next_permutation 순열찾기
GGUGGU- 2020. 4. 23. 00:032017. 10. 22에 쓰여진 글입니다.
#include <iostream>
#include <algorithm> //permutation 위한 헤더
using namespace std;
int main()
{
int a[3] = { 1,2,3 };
cout << "다음순열찾기!" << endl;
do {
for (int i = 0; i < 3; i++)
cout << a[i];
cout << endl;
} while (next_permutation(a, a + 3));
cout << endl;
cout << endl;
int b[3] = { 3, 1, 2 };
cout << "이전순열 찾기!" << endl;
do {
for (int i = 0; i < 3; i++)
cout << b[i];
cout << endl;
} while (prev_permutation(b, b + 3));
return 0;
}

※만약 벡터로 할꺼면
next_permutation(a.begin(),a.end());
'코딩, 알고리즘, 문제풀이 > 문법,알고리즘,C++,기타등등' 카테고리의 다른 글
| [C++] 팩토리얼 함수 구현하기 (0) | 2020.04.23 |
|---|---|
| [C++/STL] sort 내림차순 오름차순 (0) | 2020.04.23 |
| [C++] xor 연산을 이용한 swap (0) | 2020.04.23 |
| [C++] 비트마스킹, 비트마스크, 비트연산자 (0) | 2020.04.22 |
| [C++] 모든 부분집합을 출력하기 (0) | 2020.04.22 |
Comments