标签:排序 space post while htm div algorithm data content
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int ans[6]; int book[6],a[6],n; void dfs(int cnt) { int i,j; if(cnt==n) { for(i=0;i<n;i++) if(!i) printf("%d",ans[i]); else printf(" %d",ans[i]); printf("\n"); return ; } for(i=0;i<n;i++) { if(book[i]) continue; book[i]=1; ans[cnt]=a[i]; dfs(cnt+1); book[i]=0; while(i<n&&a[i]==a[i+1]) i++; } } int main() { while(cin>>n) { memset(book,0,sizeof(book)); memset(ans,0,sizeof(ans)); for(int i=0;i<n;i++) cin>>a[i]; dfs(0); } }
标签:排序 space post while htm div algorithm data content
原文地址:http://www.cnblogs.com/yxysuanfa/p/7196911.html