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;
        
    } 
    


  • 相关阅读:
    Exp8-Web综合
    Exp7-网络欺诈防范
    Exp6-MSF应用基础
    加密API学习
    Exp5 信息搜集与漏洞扫描
    Exp4-恶意代码分析
    Exp3-免杀原理
    Exp2-后门原理与实践
    leetcode 22括号生成 暴力法
    413 等差数列划分
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5171495.html
Copyright © 2011-2022 走看看