본문 바로가기
알고리즘 일기

전체 순열

by Beijing_KingGod 2019. 9. 2.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	vector<int> vc;

	for (int i = 0; i < 4; i++) {
		vc.push_back(i);
	}
	vector<vector<int>> temp;
	do {
		vector<int> temp2;
		for (int i = 0; i < vc.size(); i++) {
			temp2.push_back(vc[i]);
		}
		temp.push_back(temp2);
	} while (next_permutation(vc.begin(), vc.end()));
	
	for (int i = 0; i < temp.size(); i++) {
		for (int k = 0; k < temp[i].size(); k++) {
			cout<<temp[i][k];
		}
		cout << endl;
	}
	system("pause");
	return 0;
}

'알고리즘 일기' 카테고리의 다른 글

프로그래머스 다음 큰 숫자 // 이진수 변환 // 시간초과됨(해결완료)  (0) 2019.09.03
행렬 경우의수  (0) 2019.09.02
조합  (0) 2019.09.02
선택하는 순열  (0) 2019.09.02
템플릿 // char->string  (0) 2019.09.02

댓글