Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- class Student
- {
- private:
- std::string m_fio;
- std::vector<int> m_marks;
- public:
- Student(std::string &&fio, std::vector<int> &&marks) :
- m_fio{fio}, m_marks(marks){}
- Student()
- {
- m_fio = "Ivanov Ivan Ivanovich";
- m_marks = std::vector<int>{5};
- }
- const std::string &getFio() const {
- return m_fio;
- }
- void setFio(const std::string &m_fio) {
- Student::m_fio = m_fio;
- }
- const std::vector<int> &getMarks() const {
- return m_marks;
- }
- void setMarks(const std::vector<int> &m_marks) {
- Student::m_marks = m_marks;
- }
- void print()
- {
- std::cout << "Name: " << m_fio << std::endl
- << "Marks: ";
- for(auto& now : m_marks)
- std::cout << now << ' ';
- std::cout << std::endl;
- }
- bool haveScholarship()
- {
- for(auto& now : m_marks)
- if (now < 4)
- return false;
- return true;
- }
- };
- int main()
- {
- std::cout << "Enter numbers of student: ";
- unsigned n;
- std::cin >> n;
- auto *students = new Student[n];
- students[0] = Student("Alexeev Nikita Evgenevich", std::vector<int>{5, 5, 5, 5, 5});
- students[1] = Student("Ivanov Andrey Vladimirovich", std::vector<int>{3, 4, 4, 4, 5});
- students[2] = Student("Pavlov Vladislav Sergeevich", std::vector<int>{4, 5, 4, 3, 5});
- for (int i = 0; i < n; ++i)
- if (students[i].haveScholarship())
- students[i].print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement