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 yiba at 2008-10-14 13:27:00 on Problem 1029
#include<iostream>
using namespace std;


char tleft[1002][1002],tright[1002][1002],re[1002];

bool islight( int c);
bool isheavey(char c);
int find(char c,char a[]);
int K;
int main()
{
	freopen("in.txt","r",stdin);
	int N,i,a,j;
	int c,num(0),no;
	cin>>N>>K;
	for( i=0; i<K; i++)
	{
		cin>>a;
		for( j=0; j<a; j++)
		{
			cin>>c;
			tleft[i][j]=c+'0';
		}
		tleft[i][j]='\0';
		for( j=0; j<a; j++)
		{
			cin>>c;
			tright[i][j]=c+'0';
		}
		tright[i][j]='\0';
		getchar();
		cin>>re[i];

	}
	for( i=1; i<=N; i++)
	{
		if(islight(i))
		{
			
			num++;
			no=i;
			
		}
	
		
		

	}


	if(num==1)
		cout<<no<<endl;
	else
		cout<<0<<endl;



	return 0;
}
bool islight( int c)
{
	int i;
	for( i=0; i<K; i++)
	{
		if(re[i]=='=')
			if(find(c+'0',tright[i])||find(c+'0',tleft[i]))
			return false;
		if(re[i]!='=')
			if(!find(c+'0',tright[i])&&!find(c+'0',tleft[i]))
			return false;



		
		
	}
	return true;
}
int find(char c,char a[])
{
	int l=strlen(a),i;
	for( i=0; i<l; i++)
		if(a[i]==c)
			return 1;

	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