Advertisement
Guest User

Untitled

a guest
May 20th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. class Student
  6. {
  7.  
  8. private:
  9.  
  10.     std::string m_fio;
  11.     std::vector<int> m_marks;
  12.  
  13. public:
  14.  
  15.     Student(std::string &&fio, std::vector<int> &&marks) :
  16.         m_fio{fio}, m_marks(marks){}
  17.  
  18.     Student()
  19.     {
  20.         m_fio = "Ivanov Ivan Ivanovich";
  21.         m_marks = std::vector<int>{5};
  22.     }
  23.  
  24.     const std::string &getFio() const {
  25.         return m_fio;
  26.     }
  27.  
  28.     void setFio(const std::string &m_fio) {
  29.         Student::m_fio = m_fio;
  30.     }
  31.  
  32.     const std::vector<int> &getMarks() const {
  33.         return m_marks;
  34.     }
  35.  
  36.     void setMarks(const std::vector<int> &m_marks) {
  37.         Student::m_marks = m_marks;
  38.     }
  39.  
  40.     void print()
  41.     {
  42.         std::cout << "Name: " << m_fio << std::endl
  43.         << "Marks: ";
  44.         for(auto& now : m_marks)
  45.             std::cout << now << ' ';
  46.         std::cout << std::endl;
  47.     }
  48.  
  49.     bool haveScholarship()
  50.     {
  51.         for(auto& now : m_marks)
  52.             if (now < 4)
  53.                 return false;
  54.         return true;
  55.     }
  56. };
  57.  
  58. int main()
  59. {
  60.     std::cout << "Enter numbers of student: ";
  61.     unsigned n;
  62.     std::cin >> n;
  63.     auto *students = new Student[n];
  64.  
  65.     students[0] = Student("Alexeev Nikita Evgenevich", std::vector<int>{5, 5, 5, 5, 5});
  66.     students[1] = Student("Ivanov Andrey Vladimirovich", std::vector<int>{3, 4, 4, 4, 5});
  67.     students[2] = Student("Pavlov Vladislav Sergeevich", std::vector<int>{4, 5, 4, 3, 5});
  68.  
  69.     for (int i = 0; i < n; ++i)
  70.         if (students[i].haveScholarship())
  71.             students[i].print();
  72.  
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement