zoukankan      html  css  js  c++  java
  • 【杭电】[1236]排名

    这里写图片描述
    这里写图片描述

    也是WA了好多的一道题
    思路还是计算分值之后排序
    这里有个排序然后
    对考号的排序是直接比较字符串就好了

    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    using namespace std;
    struct ks {
        char s[22];
        int q;
    };
    bool vs(ks A,ks B) {
        if(A.q==B.q)
            return strcmp(A.s,B.s)<0?1:0;
        else
            return A.q>B.q;
    }
    int main() {
        int N,M,G,t,p;
        int i,j,k;
        int a[12];
        struct ks person[1200],re[1200];
        while(scanf("%d",&N),N!=0) {
            scanf("%d %d",&M,&G);
            for(i=1; i<=M; i++)
                scanf("%d",&a[i]);
            for(k=i=0; i<N; i++) {
                scanf("%s %d",&person[i].s,&t);
                for(person[i].q=j=0; j<t; j++) {
                    scanf("%d",&p);
                    person[i].q+=a[p];
                }
                if(person[i].q>=G) {
                    re[k++]=person[i];
                }
            }
            printf("%d\n",k);
            sort(re,re+k,vs);
            for(i=0; i<k; i++) {
                printf("%s %d\n",re[i].s,re[i].q);
            }
        }
        return 0;
    }

    题目地址:【杭电】[1236]排名

  • 相关阅读:
    方法参数的传递方式
    方法设计
    接口
    SQL 安装MySQL
    Windows 10 安装 wordpress
    Windows10安装PHP7+Apache 2.4
    做一个增删改查的工程
    清除缓存
    创建POJO
    VI快捷键
  • 原文地址:https://www.cnblogs.com/BoilTask/p/12570057.html
Copyright © 2011-2022 走看看