012를 조합할 때 결과가 다음과 같이 나온다.
012
021
102
120
201
210
string s = "012";
do
{
cout << s << endl;
} while (next_permutation(s.begin(), s.end()));
012를 조합할 때 결과가 다음과 같이 나온다.
000
001
002
010
011
012
020
021
022
100
101
102
110
111
112
120
121
122
200
201
202
210
211
212
220
221
222
string numbers = "012";
string mix = "";
void dfs(int h) {
if (h == N) {
cout << "조합 : " << mix << endl;
return;
}
cout << "층 : " << h << endl;
for (int i = 0; i < N; i++) {
mix += numbers[i];
dfs(h + 1);
mix.pop_back();
}
}