Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <queue>
- #include <map>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- map<string, queue<double>> students;
- string student;
- double grade;
- for (size_t i = 0; i < n; i++) {
- cin >> student;
- cin >> grade;
- students[student].push(grade);
- }
- for (auto i = students.begin(); i != students.end(); i++) {
- double sumGrades = 0;
- cout << i->first << " ->";
- int count = i->second.size();
- while (i->second.size() != 0) {
- printf(" %.2f", i->second.front());
- sumGrades += i->second.front();
- i->second.pop();
- }
- printf(" (avg: %.2f)\n", sumGrades / count);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement