Advertisement
kej

Povara

kej
Mar 16th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. struct Point
  5. {
  6.     char fio[30];
  7.     int age;
  8.     int edu;
  9.     int a[4];
  10.     int workTime;
  11.     int longestWorkTime;
  12.     int worksNum;
  13.     int fired;
  14. };
  15. void Sort(Point* A, int k)
  16. {
  17.     int i, j;
  18.     Point t;
  19.     for (i = 0; i < k - 1; i++)
  20.         for (j = i + 1; j < k; j++)
  21.             if (A[i].workTime < A[j].workTime)
  22.             {
  23.                 t = A[i];
  24.                 A[i] = A[j];
  25.                 A[j] = t;
  26.             }
  27.  
  28. }
  29. int main()
  30. {
  31.  
  32.     ifstream in("input.txt");
  33.     ofstream out("output.txt");
  34.     Point A;
  35.     int k = 0, n = 0;
  36.     int i, j;
  37.     Point* B = new Point[100];
  38.    
  39.     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))
  40.     {
  41.         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))
  42.         {
  43.             B[k] = A;
  44.             k++;
  45.         }
  46.     }
  47.    
  48.     in.close();
  49.    
  50.     Sort(B, k);
  51.     cout << "Enter number of vacant seats:  "; cin >> n;
  52.     for (i = 0; i < n; i++)
  53.     {
  54.         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;
  55.     }
  56.     out.close();
  57.  
  58.     ifstream candidates("output.txt");
  59.     ofstream chef_candidates("candidates.txt");
  60.    
  61.    Point cand;
  62.     k = 0;
  63.     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)
  64.     {
  65.        
  66.         if ((cand.age <= 45) && (cand.edu == 2) && (cand.workTime>= 15) && (cand.fired == 0) && (cand.worksNum <= 2))
  67.         {
  68.             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;
  69.             k++;
  70.         }
  71.     }
  72.     if (k==0) { chef_candidates << "Нет таковых!"; }
  73.     candidates.close();
  74.     chef_candidates.close();
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement