#include <iostream>
#include <string>
using namespace std;

class Student {
private:
    string name;
    int score;

public:
    void setInfo(string n, int s) {
        name = n;
        score = s;
    }

    int getScore() {
        return score;
    }

    string getName() {
        return name;
    }
};

int main() {
    Student students[5];

    string n;
    int s;

    for (int i = 0; i < 5; i++) {
        cin >> n >> s;
        students[i].setInfo(n, s);
    }

    int maxScore = students[0].getScore();
    string topName = students[0].getName();

    for (int i = 1; i < 5; i++) {
        if (students[i].getScore() > maxScore) {
            maxScore = students[i].getScore();
            topName = students[i].getName();
        }
    }

    cout << "\n최고 점수 학생: " << topName << " (" << maxScore << "점)" << endl;

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: