Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
PE????求大牛帮忙(附代码)#include<iostream> #include<string> using namespace std; int a[15],use[15]; int b[15]; int n; void solve(int dep,int pre,string s) { if(dep==6) { string st; int count=0; for(int f=1;f<s.length();f++) { st=s.substr(f,1); if(st==" ") count++; else count=0; if(count<2) cout<<s.substr(f,1); } cout<<endl; return; } for(int i=0;i<n;i++) { if(use[i]==0&&i>=pre) { char t[5]; string str; itoa(a[i],t,10); for(int r=0;t[r]>='0'&&t[r]<='9';r++) str+=t[r]; s=s+" "+str; use[i]=1; solve(dep+1,i,s); s=s.substr(0,s.length()-2); use[i]=0; } } } void main() { while(cin>>n) { string s; if(n==0) break; for(int j=0;j<n;j++) use[j]=0; for(int i=0;i<n;i++) cin>>a[i]; solve(0,0,s); cout<<endl; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator