Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- using namespace std;
- struct person
- {
- char fio[40];
- int year;
- char gender;
- int married;
- int child;
- char edu;
- int salary;
- };
- int main()
- {
- ifstream in("arb.txt");
- ofstream out_bin("man.bin", ios::binary);
- if (!in) {
- cout << "File not found!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
- system("pause");
- exit(1);
- }
- person x;
- person a[100];
- int i=0;
- while (in >> x.fio >> x.year >> x.gender >> x.married >> x.child >> x.edu >> x.salary) {
- if ((x.salary >= 20000) && (x.year > 1998) && (x.year <= 2001)
- && (x.child == 0) && (x.gender == 'M'))
- {
- a[i] = x;
- i++;
- }
- }
- in.close();
- int k = i;
- int j;
- for(i=0;i<k-1;i++)
- for (j = i+1; j < k; j++)
- {
- if (a[i].salary < a[j].salary)
- {
- x = a[i];
- a[i] = a[j];
- a[j] = x;
- }
- }
- for (i = 0; i < k; i++)
- cout << a[i].fio << ' ' << a[i].salary << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment