728x90
문제: https://www.acmicpc.net/problem/2754
2754번: 학점계산
어떤 사람의 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
www.acmicpc.net
해설:
1. 해당하는 성적이 주어졌을때 점수를 출력하게 해야함
2. Python에서 if와 elif만으로 간단하게 구현 가능
코드:
더보기
score = input()
if score == "A+": print(4.3)
elif score == "A0": print(4.0)
elif score == "A-": print(3.7)
elif score == "B+": print(3.3)
elif score == "B0": print(3.0)
elif score == "B-": print(2.7)
elif score == "C+": print(2.3)
elif score == "C0": print(2.0)
elif score == "C-": print(1.7)
elif score == "D+": print(1.3)
elif score == "D0": print(1.0)
elif score == "D-": print(0.7)
elif score == "F": print(0.0)
728x90
'Study > Programming' 카테고리의 다른 글
BOJ 2438번 : 별 찍기 - 1 / C언어 (0) | 2024.03.28 |
---|---|
BOJ 2557번 : Hello World / C언어 (0) | 2024.03.28 |
BOJ 10872번 : 팩토리얼 / C언어 (0) | 2024.03.28 |
BOJ 11718번 : 그대로 출력하기 / C언어 (0) | 2024.03.28 |
BOJ 5597번 : 과제 안 내신 분..? / C언어 (0) | 2024.03.28 |