Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes! | 北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

Why not AC?!!...thx

Posted by alpha7happy at 2005-10-07 15:04:06 on Problem 2245
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator