C++ 代码
#include<bits/stdc++.h>
using namespace std;
int n;
int now = 0;
int choice[15];
void func(int x){
if(x > n){
for(int i = 0; i < now; i++){
if(i != 0)
cout << " ";
cout << choice[i];
}
cout << endl;
return ;
}
func(x + 1);
choice[now++] = x;
func(x + 1);
now--;
}
int main(){
cin >> n;
func(1);
return 0;
}