zoukankan      html  css  js  c++  java
  • hdu 1236 排名

    结构体定义没搞明确,一直WA。最终AC了,真是高兴呀大笑

    代码例如以下:

    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
     struct student
    {
      char id[30];
      int  score;
    }person[1001];
    int cmp(const void *a,const void *b)
    {
        struct student *aa=(struct student *)a;
         struct student *bb=(struct student *)b;
        if(aa->score!=bb->score)
            return bb->score-aa->score;
        else
            return  strcmp(aa->id,bb->id);
    }
    int main()
    {
        int N,M,G,i,title[11],sum,tihao[10],m,j;
        
       while( scanf("%d%d%d",&N,&M,&G)!=EOF,N)
       {
         int count=0;
         for(i=1;i<=1001;i++)
         person[i].score=0;
         for(i=1;i<=M;i++)
           scanf("%d",&title[i]);
         for(i=1;i<=N;i++)
           {
              
              scanf("%s%d",person[i].id,&m);
              for(j=1;j<=m;j++)
                 {
                   scanf("%d",&tihao[j]);
                   person[i].score+=title[tihao[j]];
                 }
           }
           qsort(person+1,N,sizeof(person[1]),cmp);
           for(i=1;i<=N;i++)
           {
              if(person[i].score>=G)
              count++;
           }
           printf("%d
    ",count);
           for(i=1;i<=N;i++)
           {
             if(person[i].score>=G)
             printf("%s %d
    ",person[i].id,person[i].score);
           }
       }
        return 0;
        
    } 
    


  • 相关阅读:
    设计模式
    python高亮显示输出
    数据库入门3 数据库设计
    分支循环相关
    软件目录结构规范
    数据库入门2 数据库基础
    三级菜单
    字符串相关问题
    登录接口
    购物车
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5171495.html
Copyright © 2011-2022 走看看