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:WA了。。。。怎么回事 Posted by:adamgic at 2005-10-13 12:51:11 #include <stdio.h> #include <string.h> struct item { char par[80]; char can[80]; int l; }; void main() { int n,m,i,j; char ch[80]; scanf("%d\n",&n); item *p=new item[n]; for(i=0;i<n;i++) { gets(p[i].can); gets(p[i].par); p[i].l=0; } scanf("%d\n",&m); for(i=0;i<m;i++) { gets(ch); for(j=0;j<n;j++) if(strcmp(ch,p[j].can)==0) { p[j].l++; break; } } int counter=0,max=0,k; for(i=0;i<n;i++) { if(p[i].l>max) { counter=1; max=p[i].l; k=i; continue; } if(p[i].l==max) counter++; } if(counter!=1) printf("%s\n","tie"); else printf("%s\n",p[k].par); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator