-
Notifications
You must be signed in to change notification settings - Fork 2
/
2755.c
49 lines (43 loc) · 1.52 KB
/
2755.c
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
// [ 백준 ] 2755번: 이번학기 평점은 몇점?
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void)
{
int N;
scanf("%d", &N);
int total_credit = 0;
double total_score = 0;
for (int i = 0; i < N; i++) {
char subject[101], score[3];
int credit;
scanf("%s %d %s", &subject, &credit, &score);
if (strcmp(score, "A+") == 0) {
total_score += (credit * 4.3);
} else if (strcmp(score, "A0") == 0) {
total_score += (credit * 4.0);
} else if (strcmp(score, "A-") == 0) {
total_score += (credit * 3.7);
} else if (strcmp(score, "B+") == 0) {
total_score += (credit * 3.3);
} else if (strcmp(score, "B0") == 0) {
total_score += (credit * 3.0);
} else if (strcmp(score, "B-") == 0) {
total_score += (credit * 2.7);
} else if (strcmp(score, "C+") == 0) {
total_score += (credit * 2.3);
} else if (strcmp(score, "C0") == 0) {
total_score += (credit * 2.0);
} else if (strcmp(score, "C-") == 0) {
total_score += (credit * 1.7);
} else if (strcmp(score, "D+") == 0) {
total_score += (credit * 1.3);
} else if (strcmp(score, "D0") == 0) {
total_score += (credit * 1.0);
} else if (strcmp(score, "D-") == 0) {
total_score += (credit * 0.7);
}
total_credit += credit;
}
printf("%.2lf", round((total_score / total_credit) * 100) / 100) ;
}