Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <vector>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- class Student{
- private:
- string family;
- string firstname;
- string secondname;
- int dob;
- char sex;
- vector<int> mark;
- public:
- Student() {family = "Фамилия"; firstname = "Имя"; secondname = "Отчество"; dob = 1999; sex = 'п'; for (int i = 0; i < 3; i++) mark.push_back(0);}
- 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]);}
- char GetSex() {return sex;}
- int GetYear() {return dob;}
- string GetFamily() {return family;}
- string GetFn() {return firstname;}
- string GetSn() {return secondname;}
- int GetMarks(int i) {return mark[i];}
- };
- vector <Student> group;
- bool predict(Student ob1, Student ob2)
- {
- return ob1.GetYear() < ob2.GetYear();
- }
- void f()
- {
- vector <Student> girls;
- for (int i = 0; i < 10; i++)
- if (group[i].GetSex() == 'ж') {girls.push_back(group[i]);}
- sort(girls.begin(),girls.end(),predict);
- cout << girls[0].GetFamily() << endl;
- cout << girls[0].GetFn() << endl;
- cout << girls[0].GetSn() << endl;
- cout << girls[0].GetSex() << endl;
- cout << girls[0].GetYear() << endl;
- for (int i = 0; i < 3; i++)
- cout << girls[0].GetMarks(i) << " ";
- }
- int main()
- {
- setlocale(LC_ALL,"");
- ifstream fin("input.txt");
- if (!fin.fail()) cout << "Данные из файла успешно прочитаны\n\n";
- else {cout << "Ошибка. Файл для чтения данных не найден"; exit(0);}
- while (!fin.eof())
- {
- string f, fn, sn;
- char s;
- int year;
- vector <int> Array;
- fin >> f >> fn >> sn >> year >> s;
- int a;
- for (int i = 0; i < 3; i++)
- {
- fin >> a;
- Array.push_back(a);
- }
- Student ob1(f,fn,sn,year,s,Array);
- group.push_back(ob1);
- }
- //Print();
- f();
- fin.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement