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

Re:ss=char(a[i]+48)):that's the problem!!..use string() to change it

Posted by wsbear at 2006-08-02 02:18:46 on Problem 2245
In Reply To:Why not AC?!!...thx Posted by:alpha7happy at 2005-10-07 15:04:06
> #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