Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <fstream>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- struct student {
- string fam, imya, otch;
- int chisl, mec, year;
- int oc[5];
- int summa();
- void vvod() {
- in >> fam >> imya >> otch >> chisl >> mec >> year;
- for (int j = 0; j < 5; j++) {
- in >> oc[j];
- }
- }
- void vivod() {
- out << fam << " " << imya << " " << otch << " " << chisl << " " << mec << " " << year << " ";
- for (int j = 0; j < 5; j++) {
- out << oc[j] << " ";
- }
- out << endl;
- }
- };
- int student::summa() {
- return oc[0] + oc[1] + oc[2] + oc[3] + oc[4];
- }
- bool comparator(student left, student right) {
- return(left.summa() < right.summa()); //&& left.fam < right.fam);
- }
- int main() {
- int n;
- in >> n;
- vector <student> a;
- student t;
- for (int i = 0; i < n; i++) {
- t.vvod();
- a.push_back(t);
- }
- sort(a.begin(), a.end(), comparator);
- for (int i = 0; i < n; i++) {
- a[i].vivod();
- }
- int j;
- in >> j;
- vector <student> b;
- student y;
- for (int i = 0; i < j; i++) {
- y.vvod();
- b.push_back(y);
- }
- stable_sort(b.begin(), b.end(), comparator);
- for (int i = 0; i < j; i++) {
- b[i].vivod();
- }
- return 0;
- }
- /*
- 3
- MYLNIKOVA N S 24 7 2004 5 5 5 5 5
- mylnikova n s 24 7 2004 5 5 5 5 5
- a a a 10 2 2007 2 2 2 2 2
- 3
- MYLNIKOVA N S 24 7 2004 5 5 5 5 5
- mylnikova n s 24 7 2004 5 5 5 5 5
- a a a 10 2 2007 2 2 2 2 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement