⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.c

📁 ACM中班级排名
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAXCLASSMATE 10010


typedef struct Node Node;
struct Node
{
    char s[32];
    int k;
};


Node a[MAXCLASSMATE];
Node temp,jly;
int n,m;


int compare (const void *px,const void *py);


int main (void)
{
    int i,j,ans;
    char name[32];
    Node *p;

    strcpy (jly.s,"JLY");

    scanf ("%d",&n);
    for (i=0;i<n;i++)
        scanf ("%s",a[i].s);
    scanf ("%d",&m);

    qsort (a,n,sizeof(a[0]),compare);

    for (i=0;i<m;i++)
    {
        for (j=0;j<n;j++)
        {
            scanf ("%d%s",&temp.k,temp.s);
            p=(Node*)bsearch(&temp,a,n,sizeof(a[0]),compare);
            p->k+=temp.k;
        }

        p=(Node*)bsearch(&jly,a,n,sizeof(a[0]),compare);

        ans=1;
        for (j=0;j<n;j++)
            if (a[j].k>(p->k))
                ans++;

        printf ("%d\n",ans);
    }

    return 0;
}


int compare (const void *px,const void *py)
{
    Node *x=(Node*)px;
    Node *y=(Node*)py;

    return (strcmp(x->s,y->s));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -