码迷,mamicode.com
首页 > 其他好文 > 详细

1137 Final Grading (25分)

时间:2020-05-03 18:53:11      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:spec   hit   style   mooc   msu   base   structure   eset   div   

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 G?midterm??>G?final??, or G?final?? will be taken as the final grade G. Here G?midterm?? and G?final?? 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 G?p??‘s; the second one contains M mid-term scores G?midterm??‘s; and the last one contains N final exam scores G?final??‘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 G?p?? G?midterm?? G?final?? 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\n", x.name, x.Gp, x.Gm, x.Gf, x.G);
    }
    return 0;
}

 

1137 Final Grading (25分)

标签:spec   hit   style   mooc   msu   base   structure   eset   div   

原文地址:https://www.cnblogs.com/littlepage/p/12822642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!