문제
어떤 사람의 C언어 성적이 주어졌을 때, 평점은 몇 점인지 출력하는 프로그램을 작성하시오.
A+: 4.3, A0: 4.0, A-: 3.7
B+: 3.3, B0: 3.0, B-: 2.7
C+: 2.3, C0: 2.0, C-: 1.7
D+: 1.3, D0: 1.0, D-: 0.7
F: 0.0
입력
첫째 줄에 C언어 성적이 주어진다. 성적은 문제에서 설명한 13가지 중 하나이다.
출력
첫째 줄에 C언어 평점을 출력한다.
예제 입력 1
A0 |
예제 출력 1
4.0 |
비슷한 문제
더보기
Solution
#include<stdio.h>
int main(void)
{
float score_num=0.0;
char score[3]={'\0', };
scanf("%s", score);
if(score[0]!='F')
{
score_num+='E'-score[0];
score_num+=0.3*(score[1]=='+');
score_num-=0.3*(score[1]=='-');
}
printf("%.1f", score_num);
return 0;
}
728x90
'백준 알고리즘' 카테고리의 다른 글
<백준 알고리즘> 1964번: 오각형, 오각형, 오각형… (0) | 2020.10.22 |
---|---|
<백준 알고리즘> 2755번: 이번학기 평점은 몇점? (0) | 2020.10.22 |
<백준 알고리즘> 4504번: 배수 찾기 (0) | 2020.10.22 |
<백준 알고리즘> 15969번: 행복 (0) | 2020.10.22 |
<백준 알고리즘> 13241번: 최소공배수 (0) | 2020.10.22 |