Advertisement
palenda21

Lab8B

Dec 7th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct worker
  6. {
  7.     char surname[50];
  8.     int birthdate;
  9.     int workdate;
  10. } *spisok;
  11.  
  12. int main()
  13. {
  14.     int n;
  15.     cout << "Enter amount of workers: ";
  16.     cin >> n;
  17.     spisok = new worker[n];
  18.     for (int i = 0; i < n; i++)
  19.     {
  20.         cout << "Enter the surname of worker:  ";
  21.         cin >> spisok[i].surname;
  22.         cout << "Enter the birthdate of worker: ";
  23.         cin >> spisok[i].birthdate;
  24.         cout << "Enter the date of first work: ";
  25.         cin >> spisok[i].workdate;
  26.         cout << endl;
  27.     }
  28.    
  29.     worker temp;
  30.     for (int i = 0; i < n; i++)
  31.     {
  32.         for (int j = 0; j < n; j++)
  33.         {
  34.             if (spisok[i].workdate < spisok[j].workdate)
  35.             {
  36.                 temp = spisok[i];
  37.                 spisok[i] = spisok[j];
  38.                 spisok[j] = temp;
  39.             }
  40.             }
  41.     }
  42.  
  43.    
  44.     for (int i = 0; i < n; i++)
  45.     {
  46.         if (spisok[i].birthdate > 1985)
  47.     {
  48.         cout << spisok[i].surname << endl << "His birthdate: " << spisok[i].birthdate << endl << "His first workdate: " << spisok[i].workdate << endl;
  49.     }
  50.     }
  51.     delete[] spisok;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement