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 |
我的代码测试数据够全的了,可还是WA,悲剧啊....谁能看看哪出错了吗?#include<stdio.h> int main() { int a[10000],b[10000],c[10000],m,n,i,j,L=0,k,s,p1,p2; for(;;) { s=0; k=0; L++; while(scanf("%d%d",&m,&n)) { if(m==0&&n==0) { a[k]=m; b[k]=n; break; } if(m==-1&&n==-1) return 0; a[k]=m; b[k]=n; k++; } if(a[0]==0&&b[0]==0) { printf("Case %d is a tree.\n",L); } else { for(i=0;i<k;i++) { for(j=i+1;j<k;j++) { if(b[i]==b[j]) break; if(b[i]==a[j]&&b[j]==a[i]) break; } if(j!=k) { printf("Case %d is not a tree.\n",L); break; } if(a[i]==b[i]) { printf("Case %d is not a tree.\n",L); break; } if(a[i]==a[i+1]&&b[i]==b[i+1]) { printf("Case %d is not a tree.\n",L); break; } for(p1=0;p1<k;p1++) { for(p2=p1+1;p2<k;p2++) if(a[p1]==b[p2]) break; if(p2==k) { c[s]=a[p1]; s++; } } if(s==0) { printf("Case %d is not a tree.\n",L); break; } else { for(p1=0;p1<s-1;p1++) { if(c[p1]!=c[p1+1]) { printf("Case %d is not a tree.\n",L); break; } } if(p1!=s-1) break; } } if(i==k) printf("Case %d is a tree.\n",L); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator