Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
帮忙看一下那儿错了,谢谢#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator