|
楼主 |
发表于 2017-12-10 00:35:23
|
显示全部楼层
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
int b[10]={0,0,0,0,0,0,0,0,0,0};
int c[10]={0,0,0,0,0,0,0,0,0,0};
int k;
void dfs(int n){
if(n==0){
for(int i=1;i<=k;i++){
printf("%5d",c[i]);
}
cout<<endl;
return;
}
for(int i=n;i>=1;i--){
// cout<<"<<<<<"<<c[i]<<endl;
// cout<<"9.8"<<b[i];
if(b[i]==0){
//// cout<<"6.5"<<c[i];
c[n]=i;
b[i]=1;
cout<<i<<"<"<<c[i];
return dfs(n-1);
b[i]=0;
}
}
}
int main(){
int n;
k=n;
scanf("%d",&n);
dfs(n);
return 0;
} |
|