zoukankan      html  css  js  c++  java
  • 1137 Final Grading (25分)

    For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from the online programming assignments, and then receive a final grade no less than 60 out of 100. The final grade is calculated by 0 if Gmidterm​​>Gfinal​​, or Gfinal​​ will be taken as the final grade G. Here Gmidterm​​ and Gfinal​​ are the student's scores of the mid-term and the final exams, respectively.

    The problem is that different exams have different grading sheets. Your job is to write a program to merge all the grading sheets into one.

    Input Specification:

    Each input file contains one test case. For each case, the first line gives three positive integers: P , the number of students having done the online programming assignments; M, the number of students on the mid-term list; and N, the number of students on the final exam list. All the numbers are no more than 10,000.

    Then three blocks follow. The first block contains P online programming scores Gp​​'s; the second one contains M mid-term scores Gmidterm​​'s; and the last one contains N final exam scores Gfinal​​'s. Each score occupies a line with the format: StudentID Score, where StudentID is a string of no more than 20 English letters and digits, and Score is a nonnegative integer (the maximum score of the online programming is 900, and that of the mid-term and final exams is 100).

    Output Specification:

    For each case, print the list of students who are qualified for certificates. Each student occupies a line with the format:

    StudentID Gp​​ Gmidterm​​ Gfinal​​ G

    If some score does not exist, output "−" instead. The output must be sorted in descending order of their final grades (G must be rounded up to an integer). If there is a tie, output in ascending order of their StudentID's. It is guaranteed that the StudentID's are all distinct, and there is at least one qullified student.

    Sample Input:

    6 6 7
    01234 880
    a1903 199
    ydjh2 200
    wehu8 300
    dx86w 220
    missing 400
    ydhfu77 99
    wehu8 55
    ydjh2 98
    dx86w 88
    a1903 86
    01234 39
    ydhfu77 88
    a1903 66
    01234 58
    wehu8 84
    ydjh2 82
    missing 99
    dx86w 81
    
     

    Sample Output:

    missing 400 -1 99 99
    ydjh2 200 98 82 88
    dx86w 220 88 81 84
    wehu8 300 55 84 84

    已知输入平时成绩、其中成绩、期末成绩。我们求综合成绩,如果平时编程>=200分,才可以进行综合评定,综合评定计算方式:如果期末>期中,则选期末作为最终成绩。如果期中<=期末,则期中占比0.4,期末占比0.6,另外,我们综合评定必须在60分以上。

    最后我们进行排序,按照综合评定的G从大到小,如果G一样,再按照名字进行从小到大。

    #include <iostream>
    #include <cmath>
    #include <cstring>
    #include <map>
    #include <vector>
    #include <algorithm>
    using namespace std;
    struct stu {
        char name[30] = {0};
        int Gp = -1, Gm = -1, Gf = -1, G = -1;
    };
    bool cmp(stu& s1, stu& s2) {
        return s1.G == s2.G ? strcmp(s1.name, s2.name) < 0 : s1.G > s2.G;
    }
    map<string, stu*> m;
    int main() {
        int P, M, N;
        char a[30]; double b;
        scanf("%d%d%d", &P, &M, &N);
        while(P--) {
            scanf("%s%lf", a, &b);
            if(m[a] == NULL) m[a] = new stu();
            strcpy(m[a]->name, a);
            m[a]->Gp = b;
        }
        while(M--) {
            scanf("%s%lf", a, &b);
            if(m[a] == NULL) m[a] = new stu();
            strcpy(m[a]->name, a);
            m[a]->Gm = b;
        }
        while(N--) {
            scanf("%s%lf", a, &b);
            if(m[a] == NULL) m[a] = new stu();
            strcpy(m[a]->name, a);
            m[a]->Gf = b;
        }
        vector<stu> ans;
        for(auto x: m) {
            if(x.second->Gp >= 200) {
                if(x.second->Gm > x.second->Gf) x.second->G = round(x.second->Gm * 0.4 + x.second->Gf * 0.6);
                else x.second->G = x.second->Gf;
                if(x.second->G >= 60) ans.push_back(*x.second);
            }
        }
        sort(ans.begin(), ans.end(), cmp);
        for(auto x: ans) {
            printf("%s %d %d %d %d
    ", x.name, x.Gp, x.Gm, x.Gf, x.G);
        }
        return 0;
    }
  • 相关阅读:
    java虚拟机-内存的分配
    java-类的多态和多重继承
    java 设计模式-策略模式
    java-线程介绍和基本使用
    java 数据流操作
    java basic
    JAVA连载117-反射的应用与打破封装新
    C连载2-编译过程以及语言历史概览
    Android连载12-完善新闻app内容区域
    JavaScript连载11-Switch
  • 原文地址:https://www.cnblogs.com/littlepage/p/12822642.html
Copyright © 2011-2022 走看看