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.

25 lines
470 B

#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int a[N];
bool st[N];
int n = 3;
void dfs(int u) {
if (u == n + 1) {
for (int i = 1; i <= n; i++) cout << a[i] << " ";
cout << endl;
return;
}
for (int i = 1; i <= n; i++)
if (!st[i]) {
a[u] = i;
st[i] = true;
dfs(u + 1);
st[i] = false;
}
}
int main() {
dfs(1);
return 0;
}