| ||||||||||
| 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 | |||||||||
Why not AC?!!...thx#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int n,i;
int a[50],u[50];
string s;
void print(int dep,int x,string s) {
int i;
string ss;
char s1[10];
if (dep==6) { cout << s << endl; return;}
for (i=x;i<n;i++) {
if (!u[i]) {
u[i] = 1;
(dep==0)?(ss=char(a[i]+48)):(sprintf(s1,"%d",a[i]),ss=s+" "+string(s1));
print(dep+1,i,ss);
u[i] = 0;
}
}
}
int main() {
int t = 0;
while (cin >> n,n!=0) {
if (t++ != 0) cout << endl;
for (i=0;i<n;i++) cin >> a[i];
memset(u,0,sizeof(u));
sort(&a[0],&a[n]);
s = "";
print(0,0,s);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator