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

这两种写法到底有什么区别啊?//前的读入方式wa,改成//后的就ac了

Posted by suibian at 2005-10-13 16:01:58 on Problem 2643
#include "stdio.h"
#include "string.h"

typedef struct Node
{
    char name[100];
    char part[100];
    int c;
}node;

int cmp(const node *x,const node *y)
{
    return y->c-x->c;
}

int main()
{
    int m,n;
    int i,j;
    
    char g[100];
    char ch[100];
    node f[30];
    
    for(i=0;i<30;++i)
        f[i].c=0;
    scanf("%d",&n);getchar();             //scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
        gets(f[i].name);
        gets(f[i].part);
    }
    
    scanf("%d",&m);getchar();             //scanf("%d\n",&m);
    for(i=0;i<m;i++)
    {
        gets(g);
        strcpy(ch,g);
        for(j=0;j<n;j++)
            if(strcmp(ch,f[j].name)==0) 
            {
                f[j].c++;
                break;
            }    
    }
    qsort(f,n,sizeof(node),cmp);
    if(f[0].c==f[1].c) printf("tie");
    else if(strcmp(f[0].part,"independent")==0) 
         printf("independent");
    else printf("%s",f[0].part);
    system("pause");
}

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