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 |
呵呵,今天自以为是的多了哟In Reply To:我觉得这题目有问题,我的程序一点没错,就是通不过,题错了!!!!!!! Posted by:00448087 at 2005-07-30 21:52:32 > #include<iostream.h> > int fn( int**, int, int); > void print(int**,int,int); > void main() > { > int p,t; > cin>>p>>t; > //int *a=new int[p];//总的树木; > int **arr=new int *[p]; > for(int i=0;i<p;i++) > arr[i]=new int [102]; > int j; > for(i=0;i<p;i++) > for(j=0;j<102;j++) > arr[i][j]=0; > > int pp,tt,z=0; > while(cin>>pp>>tt) > { > z++; > arr[pp-1][tt-1]=1; > arr[pp-1][t+1]=1; > > } > //print(arr,p,t); > if(z!=0){ > int total=fn(arr,p,t); > // print(arr,p,t); > cout<<total<<endl; > } > else cout<<0<<endl; > } > int fn(int **arr,int p,int t) > { > int pp=1,i=0,j,k,q=0; > for(i=0;i<p;i++) > if(arr[i][t+1]==1) > for(j=i+1;j<p;j++) > if(arr[j][t]==0&&arr[j][t+1]==1) > { > for(k=0;k<t;k++){ > > if(arr[i][k]!=arr[j][k]) > { > pp++; > //cout<<"pp="<<pp<<" i="<<i<<" j="<<j<<endl; > break; > } > else q++; > } > > if(q==t) > {arr[j][t]=1;}//cout<<"arr["<<j<<"]"<<endl;} > q=0; > } > > > return pp ; > } > void print(int **arr,int p,int t) > { > for(int i=0;i<p;i++) > { > for(int j=0;j<t+2;j++) > cout<<arr[i][j]<<' '; > cout<<endl; > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator