Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
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
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 11367번 Report Card Time 본문

YJ/C++

[백준/BOJ/C++] 11367번 Report Card Time

Team DAON 2021. 11. 8. 16:56

[문제]

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";
	}
}

[결과 화면]