Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why is it wrong?

Posted by woaixiyuan at 2008-04-16 17:52:14 on Problem 2643
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator