Files
python/TangDou/LanQiaoBei/LanQiao12ShengSai/BC4_dfs_Prepare.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

26 lines
458 B
C++

#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;
}