Advertisement
mercMatvey4

Untitled

May 26th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <vector>
  4. #include <fstream>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. class Student{
  10. private:
  11. string family;
  12. string firstname;
  13. string secondname;
  14. int dob;
  15. char sex;
  16. vector<int> mark;
  17. public:
  18. Student() {family = "Фамилия"; firstname = "Имя"; secondname = "Отчество"; dob = 1999; sex = 'п'; for (int i = 0; i < 3; i++) mark.push_back(0);}
  19. Student(string fam, string fn, string sn, int year, char s, vector<int> &arr) {family = fam; firstname = fn; secondname = sn; dob = year; sex = s; for (int i = 0; i < 3; i++) mark.push_back(arr[i]);}
  20. char GetSex() {return sex;}
  21. int GetYear() {return dob;}
  22. string GetFamily() {return family;}
  23. string GetFn() {return firstname;}
  24. string GetSn() {return secondname;}
  25. int GetMarks(int i) {return mark[i];}
  26. };
  27.  
  28. vector <Student> group;
  29.  
  30. bool predict(Student ob1, Student ob2)
  31. {
  32. return ob1.GetYear() < ob2.GetYear();
  33. }
  34.  
  35. void f()
  36. {
  37. vector <Student> girls;
  38. for (int i = 0; i < 10; i++)
  39. if (group[i].GetSex() == 'ж') {girls.push_back(group[i]);}
  40. sort(girls.begin(),girls.end(),predict);
  41. cout << girls[0].GetFamily() << endl;
  42. cout << girls[0].GetFn() << endl;
  43. cout << girls[0].GetSn() << endl;
  44. cout << girls[0].GetSex() << endl;
  45. cout << girls[0].GetYear() << endl;
  46. for (int i = 0; i < 3; i++)
  47. cout << girls[0].GetMarks(i) << " ";
  48. }
  49.  
  50. int main()
  51. {
  52. setlocale(LC_ALL,"");
  53. ifstream fin("input.txt");
  54. if (!fin.fail()) cout << "Данные из файла успешно прочитаны\n\n";
  55. else {cout << "Ошибка. Файл для чтения данных не найден"; exit(0);}
  56. while (!fin.eof())
  57. {
  58. string f, fn, sn;
  59. char s;
  60. int year;
  61. vector <int> Array;
  62. fin >> f >> fn >> sn >> year >> s;
  63. int a;
  64. for (int i = 0; i < 3; i++)
  65. {
  66. fin >> a;
  67. Array.push_back(a);
  68. }
  69. Student ob1(f,fn,sn,year,s,Array);
  70. group.push_back(ob1);
  71. }
  72. //Print();
  73. f();
  74. fin.close();
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement