You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
458 B
26 lines
458 B
#include <bits/stdc++.h>
|
|
|
|
// https://www.acwing.com/solution/content/34401/
|
|
using namespace std;
|
|
const int N = 20;
|
|
int a[N];
|
|
bool st[N];
|
|
|
|
int n = 3;
|
|
|
|
void dfs(int step) {
|
|
if (step == n + 1) {
|
|
for (int i = 1; i <= n; i++)printf("%d ", a[i]);
|
|
printf("\n");
|
|
return;
|
|
}
|
|
for (int i = 1; i <= n; i++) {
|
|
a[step] = i;
|
|
dfs(step + 1);
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
dfs(1);
|
|
return 0;
|
|
} |