zoukankan      html  css  js  c++  java
  • 1137 Final Grading

    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​mid−term​​>G​final​​, or G​final​​ will be taken as the final grade G. Here G​mid−term​​ 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​mid−term​​'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​mid−term​​ 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,所以编程成绩小于200的直接过滤掉,接下来输入的时候不用考虑。

    Code:

    #include <bits/stdc++.h>
    
    using namespace std;
    
    typedef struct Student* student;
    
    struct Student {
        string Id;
        int Gp;
        int Gm;
        int Gf;
        int final;
        Student(string id) {
            Id = id;
            Gp = -1;
            Gm = -1;
            Gf = -1;
        }
    };
    
    bool cmp(student a, student b) {
        if (a->final != b->final)
            return a->final > b->final;
        else
            return a->Id < b->Id;
    }
    
    int main() {
        int P, M, N, score;
        string id;
        cin >> P >> M >> N;
        map<string, student> mp;
        for (int i = 0; i < P; ++i) {
            cin >> id >> score;
            if (score < 200) continue;
            student stu = new Student(id);
            stu->Gp = score;
            mp[id] = stu;
        }
        for (int i = 0; i < M; ++i) {
            cin >> id >> score;
            if (mp.find(id) != mp.end()) {
                mp[id]->Gm = score;
            }
        }
        for (int i = 0; i < N; ++i) {
            cin >> id >> score;
            if (mp.find(id) != mp.end()) {
                mp[id]->Gf = score;
                int final = score > mp[id]->Gm
                                ? score
                                : (mp[id]->Gm * 0.4 + score * 0.6 + 0.5);
                mp[id]->final = final;
            }
        }
        vector<student> stu;
        for (auto it : mp) {
            if (it.second->final >= 60 && it.second->final <= 100)
                stu.push_back(it.second);
        }
        sort(stu.begin(), stu.end(), cmp);
    
        for (int i = 0; i < stu.size(); ++i) {
            cout << stu[i]->Id << " " << stu[i]->Gp << " " << stu[i]->Gm << " "
                 << stu[i]->Gf << " " << stu[i]->final << endl;
        }
    
        return 0;
    }
    永远渴望,大智若愚(stay hungry, stay foolish)
  • 相关阅读:
    storm原理写得比较好的文章
    maven设置jdk版本
    项目中记录log4j记录日志
    eclipse jadeclipse配置
    Maven使用说明
    crond不执行原因分析
    空调遥控器图标含义
    window7开放端sqlserver端口
    servlet仿struts参数注入
    cocos 2dx-js3.5整合anySDK
  • 原文地址:https://www.cnblogs.com/h-hkai/p/12728377.html
Copyright © 2011-2022 走看看