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

新手求助——ps[501]为什么不对啊 开到10001就对 很是不明白——

Posted by wangyanyan at 2011-11-02 23:36:20 on Problem 2092 and last updated at 2011-11-02 23:37:00
#include <stdio.h>
#include <string.h>

int ps[501];//player's score
int main()
{
    int N,M,i,t,t1,t2,f,s;
    while(scanf("%d%d",&N,&M)!=EOF&&N)
    {
        memset(ps,0,sizeof(ps));
        scanf("%d",&t);
        ps[t]++;
        t1=t2=t;
        for(i=1;i<N*M;i++)
        {
            scanf("%d",&t);
            ps[t]++;
            if(t<t1) t1=t;
            if(t>t2) t2=t;
        }
        for(i=t1,f=1;i<=t2;i++)
        if(ps[i]>f) f=ps[i];

        for(i=t1,s=0;i<=t2;i++)
        {
            if(ps[i]!=f && ps[i]>s) s=ps[i];
        }
        for(i=t1;i<=t2;i++)
        if(ps[i]==s) printf("%d ",i);
        printf("\n");

    }

    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