#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
struct Student {
string first_name;
string last_name;
char grade;
};
int main() {
vector<Student> students;
while (true) {
Student new_student;
if (!(cin >> new_student.first_name >> new_student.last_name >> new_student.grade)) break;
students.push_back(new_student);
}
map<char, vector<Student>> grade_map;
for (const auto& student : students) {
grade_map[student.grade].push_back(student);
}
for (char grade = 'A'; grade <= 'F'; ++grade) {
cout << "Students with grade " << grade << ":" << endl;
for (const auto& student : grade_map[grade]) {
cout << student.first_name << " " << student.last_name << endl;
}
cout << endl;
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: