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 |
why is it wrong?#include<stdio.h> #include<string.h> int main() { char name[10010][100]; char party[30][100],candi[30][100]; int i,j,m,n,p,t,temp,max,vote[30]; scanf("%d",&n); getchar(); for(i=0;i<n;i++) { gets(candi[i]); gets(party[i]); vote[i]=0; } scanf("%d",&m); getchar(); for(j=0;j<m;j++) { gets(name[j]); for(i=0;i<n;i++) { if(strcmp(name[j],candi[i])==0) { vote[i]++; } } } p=0; for(i=1;i<n;i++) { if(vote[p]<vote[i]) { p=i; } } max=vote[p]; for(j=0;j<n;j++) { if(p==j) continue; if(max==vote[i]) { printf("tie\n");break; } } if(j==n) printf("%s\n",party[p]); return(0); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator