근본없는 코딩

[C++] 백준25206 너의 평점은 본문

✔ Online Judge

[C++] 백준25206 너의 평점은

근본없는 개발자 2023. 6. 29. 23:56

 

#include <iostream>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout.precision(6);

	char leacture[100], credit[5], grade[5];
	double s = 0, c = 0, total = 0;


	for (int i = 0; i < 20; i++) {
		cin >> leacture >> credit >> grade;

		switch (grade[0]) {
			case 'A': s = 4; break;
			case 'B': s = 3; break;
			case 'C': s = 2; break;
			case 'D': s = 1; break;
			case 'F': s = 0; break;
			case 'P': s = 0; credit[0] = '0'; break;
		}
		if (grade[1] == '+') s += 0.5;

		c += credit[0] - '0';
		total += (credit[0] - '0') * s;
		
	}
	cout << total/c << '\n';


	return 0;
}