Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define Line cout << "--------------------------------------------------\n"
- #define forn(i, n) for(int i = 0; i < int(n);i++)
- const int INF = 1e9 + 13;
- const int N = 1e5 + 13;
- ifstream in("input.txt");
- struct student{
- int group;
- string first_name, second_name, third_name;
- int birth_year;
- int marks[5];
- void print();
- };
- void student::print(){
- Line;
- cout << "Full name: " << first_name << ' ' << second_name << ' ' << third_name << "\nbirth year: " << birth_year <<
- "\n" << "marks: " << marks[0] << ' ' << marks[1] << ' ' << marks[2] << ' ' << marks[3] << ' ' << marks[4] << endl;
- }
- bool check(student a, student b){
- if (a.first_name < b.first_name)
- return true;
- else
- if (a.second_name < b.second_name && a.first_name == b.first_name)
- return true;
- else
- if (a.third_name < b.third_name && a.second_name == b.second_name)
- return true;
- return false;
- }
- void MySort(student* a, int n){
- forn(i, n){
- student Min = a[i];
- int idx = i;
- for (int j = i + 1; j < n; ++j)
- {
- if (check(a[j], a[idx]))
- {
- Min = a[j];
- idx = j;
- }
- }
- swap(a[i], a[idx]);
- }
- }
- student get_student(){
- student res;
- in >> res.group;
- in >> res.first_name >> res.second_name >> res.third_name;
- in >> res.birth_year;
- forn(i, 5)
- in >> res.marks[i];
- return res;
- }
- student a[N];
- int main(){
- int n = 0;
- while (in.peek() != EOF)
- {
- a[n] = get_student();
- if (a[n].first_name == "")
- n--;
- n++;
- }
- MySort(a, n);
- forn(i, n)
- a[i].print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement