You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
1.9 KiB
97 lines
1.9 KiB
#include <iostream>
|
|
#include <cmath>
|
|
|
|
using namespace std;
|
|
|
|
class CStudent {
|
|
public:
|
|
int getId() const;
|
|
|
|
void setId(int id);
|
|
|
|
int getScore() const;
|
|
|
|
void setScore(int score);
|
|
|
|
CStudent(int id, string name, int score);
|
|
|
|
void setName(const string &name);
|
|
|
|
const string &getName() const;
|
|
|
|
CStudent(const CStudent &source);
|
|
|
|
CStudent();
|
|
|
|
private:
|
|
int id = 0;
|
|
string name;
|
|
int score = 0;
|
|
};
|
|
|
|
int CStudent::getId() const {
|
|
return id;
|
|
}
|
|
|
|
void CStudent::setId(int id) {
|
|
CStudent::id = id;
|
|
}
|
|
|
|
void CStudent::setName(const string &name) {
|
|
CStudent::name = name;
|
|
}
|
|
|
|
const string &CStudent::getName() const {
|
|
return name;
|
|
}
|
|
|
|
int CStudent::getScore() const {
|
|
return score;
|
|
}
|
|
|
|
void CStudent::setScore(int score) {
|
|
CStudent::score = score;
|
|
}
|
|
|
|
CStudent::CStudent(int id, string name, int score) : id(id), name(name), score(score) {}
|
|
|
|
CStudent::CStudent() : id(0), name("name"), score(0) {}
|
|
|
|
CStudent::CStudent(const CStudent &source) {
|
|
id = source.id;
|
|
name = source.name;
|
|
score = source.score;
|
|
}
|
|
|
|
#include <vector>
|
|
|
|
int main() {
|
|
vector<CStudent> students;
|
|
|
|
int studentAmount = 0;
|
|
cout << "Enter the amount of students: ";
|
|
cin >> studentAmount;
|
|
|
|
int maxScore = 0;
|
|
for (int i = 0; i < studentAmount; ++i) {
|
|
int id = 0;
|
|
int score = 0;
|
|
string name = "";
|
|
|
|
cin >> id >> name >> score;
|
|
CStudent student(id, name, score);
|
|
students.push_back(student);
|
|
|
|
if (maxScore < score) {
|
|
maxScore = score;
|
|
}
|
|
}
|
|
|
|
for (const CStudent &student: students) {
|
|
if (student.getScore() == maxScore) {
|
|
cout << "id: " << student.getId()
|
|
<< ", name: " << student.getName()
|
|
<< ", score: " << student.getScore() << endl;
|
|
}
|
|
}
|
|
}
|
|
|