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

PE????求大牛帮忙(附代码)

Posted by fortunato at 2008-01-29 20:20:25 on Problem 2245 and last updated at 2008-01-29 20:21:18
#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:
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