2.Abiturient: Прізвище, Ім'я, По-батькові, Сума балів, Номер спеціальністі.
Створити масив об'єктів. Вивести:
а) список абітурієнтів, які мають незадовільні оцінки;
в) вибрати N абітурієнтів, які мають найвищу суму балів по заданої спеціальності.
Написать на c++
Ответы
Відповідь:
C++ code:
#include <iostream>
#include <string>
class Abiturient{
private:
std::string surname;
std::string name;
std::string middle_name;
int sum_score;
int number_spec;
public:
Abiturient();
Abiturient(std::string,std::string,std::string,int,int);
Abiturient(const Abiturient& );
~Abiturient() = default;
void set_surname(std::string surname){ this->surname = surname; }
void set_name(std::string name){ this->name = name; }
void set_middle_name(std::string middle_name){ this->middle_name = middle_name; }
void set_sum_score(int sum_score){ this->sum_score = sum_score; }
void set_number_spec(int number_spec){ this->number_spec = number_spec; }
std::string get_surname(){ return surname; }
std::string get_name(){ return name; }
std::string get_middle_name(){ return middle_name; }
int get_sum_score(){ return sum_score; }
int get_number_spec(){ return number_spec; }
};
Abiturient::Abiturient(){
surname = "surname";
name = "name";
middle_name = "middle_name";
sum_score = 0;
number_spec = 0;
}
Abiturient::Abiturient(std::string surname,std::string name,std::string middle_name,int sum_score,int number_spec){
this->surname = surname;
this->name = name;
this->middle_name = middle_name;
this->sum_score = sum_score;
this->number_spec = number_spec;
}
Abiturient::Abiturient(const Abiturient& obj){
this->name = obj.name;
this->surname = obj.surname;
this->middle_name = obj.middle_name;
this->sum_score = obj.sum_score;
this->number_spec = obj.number_spec;
}
int main(){
setlocale(LC_ALL , "Ukrainian");
int size;
std::cout << "Введiть кiлькiсть студентiв: ";
std::cin >> size;
Abiturient *List_students = new Abiturient[size];
delete[] List_students;
return 0;
}
Пояснення:
Описано клас та створено динамічний масив об'єктів,дальше все у ваших руках