'commit'
This commit is contained in:
26
TangDou/LanQiaoBei/LanQiao12ShengSai/BC4_dfs_Prepare.cpp
Normal file
26
TangDou/LanQiaoBei/LanQiao12ShengSai/BC4_dfs_Prepare.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user