Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- struct Student
- {
- string firstName, surname, lastName;
- int yearOfBirdth;
- int mark[5];
- int sum = 0;
- void get()
- {
- in >> firstName >> surname >> lastName >> yearOfBirdth;
- for (int i = 0; i < 5; ++i)
- {
- in >> mark[i];
- sum += mark[i];
- }
- }
- void print()
- {
- out << firstName << ' ' << surname << ' '<< lastName << '\n' << yearOfBirdth << '\n';
- for (int i = 0; i < 5; ++i)
- out << mark[i] << ' ';
- out << '\n' << "sum :" << sum << "\n\n";
- }
- };
- const int MAXSIZE = 100;
- int main()
- {
- Student a[MAXSIZE];
- int n = 0;
- int group;
- in >> group;
- while (in.peek() != EOF)
- {
- a[n].get();
- n++;
- }
- for (int i = 0; i < n; ++i)
- {
- int idx = i;
- for (int j = i; j < n; ++j)
- if (a[j].sum < a[idx].sum)
- idx = j;
- Student cur = a[idx];
- a[idx] = a[i];
- a[i] = cur;
- }
- out << group << "\n\n";
- for (int i = 0; i < n; ++i)
- a[i].print();
- /*
- пример входного файла:
- 181
- krisa V S
- 2001
- 2 2 2 2 2
- Ololosha D V
- 2000
- 5 5 5 5 5
- Akakij K A
- 2002
- 1 2 3 4 5
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement