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

看看这段代码,为什么不能通过?

Posted by qicaiqinxian at 2007-11-03 18:20:58 on Problem 3445
#include<iostream>
#include<cstdlib>
using namespace std;
int sum[20];

void output(int n)
{
	int i;
	if(n==0){ cout<<"{}";return ;}
	else 
	{
		  cout<<"{";
		  for(i=0;i<n;i++)
		  {  
			  output(i);
			  if(i!=n-1)cout<<",";
		  }
		  cout<<"}";
	}
	return ;
}

int count(char *a)
{
	int i,la=strlen(a),t=0;
	if(la==2) return 0;
	for(i=0;i<la;i++)
		if(a[i]==',')t++;
	for(i=1;i<16;i++)
		if(t==sum[i]) return i;
}

int main()
{
	int i,j,n,total;
	char a[50000],b[50000];
	sum[0]=0;
	sum[1]=0;
	for(i=2;i<16;i++)
	{
		sum[i]=i-1;
		for(j=2;j<i;j++)
			sum[i]+=sum[j];
	}
	cin>>n;
	i=0;
	while(i<n)
	{
		i++;
		memset(a,0,sizeof(a));
		cin>>a;
		cin>>b;
		total=count(a)+count(b);
		output(total);
		cout<<endl;
	}
	return 0;
}



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