Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include<string>
  2. #include<iostream>
  3. #include<fstream>
  4. using namespace std;
  5. ifstream in("in.txt");
  6. ofstream out("out.txt");
  7. struct unic {
  8.     string numgr, fam, im, ot, year;
  9.     int f, ff, fff, ffff;
  10.     void print();
  11. };
  12. void unic::print() {
  13.     out << numgr << ' ' << fam << ' ' << im << ' ' << ot << ' ' << year << ' ' << f << ' ' << ff << ' ' << fff << ' ' << ffff << endl;
  14. }
  15. int main() {
  16.     setlocale(LC_ALL, "russian");
  17.     unic swap,a[5];
  18.     for (int i = 0; i < 5; i++) {
  19.         in >>a[i].numgr>>a[i].fam >> a[i].im >> a[i].ot>> a[i].year >> a[i].f >> a[i].ff>>a[i].fff>>a[i].ffff;
  20.     }
  21.     for (int i = 0; i < 5; i++) {
  22.         for (int j = 0; j < 4; j++) {
  23.             if (a[j].fam > a[j + 1].fam) {
  24.                 swap = a[j];
  25.                 a[j] = a[j + 1];
  26.                 a[j + 1] = swap;
  27.             }
  28.         }
  29.     }      
  30.     out << "По фамилии:" << endl;
  31.     for (int i = 0; i < 5; i++) {
  32.         a[i].print();
  33.     }
  34.     for (int i = 0; i < 5; i++) {
  35.         for (int j = 0; j < 4; j++) {
  36.             if (a[j].year < a[j + 1].year) {
  37.                 swap = a[j];
  38.                 a[j] = a[j + 1];
  39.                 a[j + 1] = swap;
  40.             }
  41.         }
  42.     }
  43.     out << "По году рождения:" << endl;
  44.     for (int i = 0; i < 5; i++) {
  45.         a[i].print();
  46.     }
  47.     system("pause");
  48.     in.close();
  49.     out.close();
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement