Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm>
- #include <string>
- #include <vector>
- using namespace std;
- struct Person
- {
- string name;
- string secondname;
- string surname;
- int year;
- int marks [5];
- };
- ifstream in("input.txt");
- ofstream out ("output.txt");
- bool fun (Person &x, Person &y )
- {
- if (x.surname == y.surname)
- return x.year > y.year;
- else return x.surname < y.surname;
- }
- void print(Person &x)
- {
- out << x.surname << " " << x.name << " " << x.secondname << " " << x.year << " ";
- for(int i = 0; i < 5; i++)
- out << x.marks[i] << " ";
- out << endl;
- }
- int main()
- {
- vector <Person> vec;
- Person List;
- int n;
- in >> n;
- for(int i = 0; i < n; i++)
- {
- in >> List.surname;
- in >> List.name;
- in >> List.secondname;
- in >> List.year;
- for(int i = 0; i < 5; i++)
- in >> List.marks[i];
- vec.push_back(List);
- }
- sort(vec.begin(), vec.end(), fun);
- for_each(vec.begin(), vec.end(), print);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement