코딩로그
[백준/BOJ/C++] 11367번 Report Card Time 본문
[문제]
Little hobbitses go to hobbit school in the Shire. They just finished a course, which involved tea-making, meal-eating, nap-taking, and gardening. Based on the following grading scale, assign each hobbit a letter grade based on their final numerical course grade.
- A+: 97-100
- A: 90-96
- B+: 87-89
- B: 80-86
- C+: 77-79
- C: 70-76
- D+: 67-69
- D: 60-66
- F: 0-59
[입력]
The input will begin with a single line containing just a whole number, n, of the number of hobbits in the class, followed by n lines in the form a b, where a is the hobbit’s name (only alphabetical characters) and b is the hobbit’s grade, given as a whole number. The length of hobbit's name is less than 10.
[출력]
For each test case, print out a list of every hobbits name and letter grade, each on its own line. There should be no additional white space following test cases.
[Source Code]
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
string change(int num){
if(num >= 97)
return "A+";
else if(num >= 90)
return "A";
else if(num >= 87)
return "B+";
else if(num >= 80)
return "B";
else if(num >= 77)
return "C+";
else if(num >= 70)
return "C";
else if(num >= 67)
return "D+";
else if(num >= 60)
return "D";
else
return "F";
}
int main() {
int test;
cin >> test;
for(int i = 0; i < test; i++){
string name;
int score;
cin >> name >> score;
cout << name <<" " <<change(score) << "\n";
}
}
[결과 화면]
'YJ > C++' 카테고리의 다른 글
[백준/BOJ/C++] 6763번 Speed fines are not fine! (0) | 2021.11.08 |
---|---|
[백준/BOJ/C++] 16503번 괄호 없는 사칙연산 (0) | 2021.11.08 |
[백준/BOJ/C++] 11549번 Identifying Tea (0) | 2021.11.08 |
[백준/BOJ/C++] 12790번 Mini Fantasy War (0) | 2021.11.08 |
[백준/BOJ/C++] 11557번 Yangjojang of The Year (0) | 2021.11.08 |