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.

23 lines
362 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N], al, n;
void dfs(int u) {
if (u == n + 1) return;
a[++al] = u;
// 立即输出
for (int i = 1; i <= al; i++) cout << a[i] << " ";
cout << endl;
dfs(u + 1);
al--;
dfs(u + 1);
}
int main() {
cin >> n;
dfs(1);
return 0;
}