JouJoy

Untitled

Mar 2nd, 2020
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3. using namespace std;
  4.  
  5. struct person
  6. {
  7.     char fio[40];
  8.     int year;
  9.     char gender;
  10.     int married;
  11.     int child;
  12.     char edu;
  13.     int salary;
  14. };
  15. int main()
  16. {
  17.     ifstream in("arb.txt");
  18.     ofstream out_bin("man.bin", ios::binary);
  19.     if (!in) {
  20.         cout << "File not found!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
  21.         system("pause");
  22.         exit(1);
  23.     }
  24.     person x;
  25.     person a[100];
  26.     int i=0;
  27.     while (in >> x.fio >> x.year >> x.gender >> x.married >> x.child >> x.edu >> x.salary) {
  28.         if ((x.salary >= 20000) && (x.year > 1998) && (x.year <= 2001)
  29.             && (x.child == 0) && (x.gender == 'M'))
  30.         {
  31.             a[i] = x;
  32.             i++;
  33.         }
  34.     }
  35.     in.close();
  36.     int k = i;
  37.     int j;
  38.     for(i=0;i<k-1;i++)
  39.         for (j = i+1; j < k; j++)
  40.         {
  41.             if (a[i].salary < a[j].salary)
  42.             {
  43.                 x = a[i];
  44.                 a[i] = a[j];
  45.                 a[j] = x;
  46.             }
  47.         }
  48.     for (i = 0; i < k; i++)
  49.         cout << a[i].fio << ' ' << a[i].salary << endl;
  50.     system("pause");
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment