-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path25206_너의평점은.cpp
64 lines (49 loc) · 1.04 KB
/
25206_너의평점은.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
double sumGrade = 0;
double sumCredit = 0;
double avg = 0;
map<string, double>m;
void calcGrade(double credit, string grade) {
if (grade == "P") {
return ;
}
sumCredit += credit;
if (m.find(grade) != m.end()) {
sumGrade += m[grade]* credit;
}
}
void setMap() {
m.insert(make_pair("A+", 4.5));
m.insert(make_pair("A0", 4.0));
m.insert(make_pair("B+", 3.5));
m.insert(make_pair("B0", 3.0));
m.insert(make_pair("C+", 2.5));
m.insert(make_pair("C0", 2.0));
m.insert(make_pair("D+", 1.5));
m.insert(make_pair("D0", 1.0));
m.insert(make_pair("F", 0.0));
//m.insert(make_pair("P", 10000.0));
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout << fixed;
cout.precision(6);
setMap();
for (int i = 0; i < 20; i++) {
string subject;
double credit;
string grade;
cin >> subject >> credit >> grade;
calcGrade(credit, grade);
}
avg = sumGrade / sumCredit;
cout << avg;
return 0;
}