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 00448162 at 2005-04-23 20:53:06 on Problem 2419
#include <iostream.h>
bool isSame( int *, int *, int );
#define N 101
 
void main()
{
	int t, p, i, j;
	int sum = 0;
	int array[N][N];
	cin>> p>> t;

	for( i = 0; i < N; i ++ )
	{
		for( j = 0; j < N; j ++ )
			array[i][j] = 0;
	}

	if(( p==0 ) || ( t ==0 ))
		cout<< 1;
	else
	{
		int tree, people;
	
		while( cin>> people>> tree )
		{
			array[people][tree] = 1;
		}

		for( i = 1; i <= p ; i ++ )
		{
			if( array[i][t + 1] != 1 )
			{
				for( j = i +1; j <= p; j ++ )
				{
					if( array[j][t + 1] != 1 )
					{
						if( isSame( array[i], array[j], t ))
						{
							sum ++;
							array[i][t + 1] = 1;
							array[j][t + 1] = 1;
						}
					}
				}
			}
		}

		for( i = 1; i <= p; i ++ )
		{
			if( array[i][t + 1] == 0 )
				sum ++;
		}

		cout<< sum<< endl;
	}
} 

bool isSame( int *a, int *b, int size )
{

	for( int k = 1; k <= size; k ++ )
	{
		if( a[k] != b[k] )
			return false;
	}
		return true;
}




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