BOJ 25206 너의 평점은

1 개요[ | ]

BOJ 25206 너의 평점은


2 C++[ | ]

#include <iostream>
#include <string>
using namespace std;

float grade2score(string grade) {
    if(grade == "A+") return 4.5;
    if(grade == "A0") return 4.0;
    if(grade == "B+") return 3.5;
    if(grade == "B0") return 3.0;
    if(grade == "C+") return 2.5;
    if(grade == "C0") return 2.0;
    if(grade == "D+") return 1.5;
    if(grade == "D0") return 1.0;
    if(grade == "F") return 0.0;
    return -9999;
}

int main() {
    string name;
    float hour;
    string grade;
    float total_hour = 0;
    float total_score = 0;
    for(int i=0; i<20; i++) {
        cin >> name >> hour >> grade;
        if(grade == "P") continue;
        total_hour += hour;
        total_score += hour * grade2score(grade);
    }
    cout << total_score/total_hour << '\n';
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}