Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct Point
- {
- char fio[30];
- int age;
- int edu;
- int a[4];
- int workTime;
- int longestWorkTime;
- int worksNum;
- int fired;
- };
- void Sort(Point* A, int k)
- {
- int i, j;
- Point t;
- for (i = 0; i < k - 1; i++)
- for (j = i + 1; j < k; j++)
- if (A[i].workTime < A[j].workTime)
- {
- t = A[i];
- A[i] = A[j];
- A[j] = t;
- }
- }
- int main()
- {
- ifstream in("input.txt");
- ofstream out("output.txt");
- Point A;
- int k = 0, n = 0;
- int i, j;
- Point* B = new Point[100];
- while ((in >> A.fio >> A.age >> A.edu >> A.a[0] >> A.a[1] >> A.a[2] >> A.a[3] >> A.workTime >> A.longestWorkTime >> A.worksNum >> A.fired))
- {
- if ((A.age <= 50) && (A.edu == 2 || A.edu == 1) && (A.a[0]==1)|| (A.a[1]==1) && (A.workTime >= 5) && (A.longestWorkTime >= A.workTime/2) && (A.fired <=1) && (A.worksNum <=5))
- {
- B[k] = A;
- k++;
- }
- }
- in.close();
- Sort(B, k);
- cout << "Enter number of vacant seats: "; cin >> n;
- for (i = 0; i < n; i++)
- {
- out << B[i].fio << " " << B[i].age << " " << B[i].edu << " " << B[i].a[0] << " " << B[i].a[1] << " " << B[i].a[2] << " " << B[i].a[3] << " " << B[i].workTime << " " << B[i].longestWorkTime << " " << B[i].worksNum << " " << B[i].fired << endl;
- }
- out.close();
- ifstream candidates("output.txt");
- ofstream chef_candidates("candidates.txt");
- Point cand;
- k = 0;
- while (candidates >> cand.fio >> cand.age >> cand.edu >> cand.a[0] >> cand.a[1] >> cand.a[2] >> cand.a[3] >> cand.workTime >> cand.longestWorkTime >> cand.worksNum >> cand.fired)
- {
- if ((cand.age <= 45) && (cand.edu == 2) && (cand.workTime>= 15) && (cand.fired == 0) && (cand.worksNum <= 2))
- {
- chef_candidates << cand.fio << " " << cand.age << " " << cand.edu << " " << cand.a[0] << " " << cand.a[1] << " " << cand.a[2] << " " << cand.a[3] << " " << cand.workTime << " " << cand.longestWorkTime << " " << cand.worksNum << " " << cand.fired << endl;
- k++;
- }
- }
- if (k==0) { chef_candidates << "Нет таковых!"; }
- candidates.close();
- chef_candidates.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement