SHARE
TWEET

Untitled

a guest May 20th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "pch.h";
  2. #include <iostream>
  3. #include <fstream>
  4. using namespace std;
  5. struct zajavka
  6. {
  7.     char fio[40];
  8.     int age;
  9.     int edu;
  10.     int kitch[4];
  11.     int exp;
  12.     int max_period;
  13.     int num_jobs;
  14.     int dismiss;
  15. };
  16. int main()
  17. {
  18.     ifstream in("input.txt");
  19.     ofstream out("pret.bin", ios::binary);
  20.     zajavka a[100];
  21.     zajavka x;
  22.     int i = 0;
  23.     while (in >> x.fio >> x.age >> x.edu >> x.kitch[0] >> x.kitch[1] >> x.kitch[2] >> x.kitch[3] >> x.exp >> x.max_period >> x.num_jobs >> x.dismiss)
  24.         if (x.age <= 50 && x.edu && (x.kitch[0] || x.kitch[1]) && x.exp >= 5 && 2 * x.max_period >= x.exp && x.dismiss <= 1 && x.num_jobs <= 5)
  25.         {
  26.             a[i] = x;
  27.             i++;
  28.         }
  29.     int k = i;
  30.     for (i = 0; i < k - 1; i++)
  31.         for (int j = i + 1; j < k; j++)
  32.             if (a[i].exp < a[j].exp)
  33.             {
  34.                 x = a[i];
  35.                 a[i] = a[j];
  36.                 a[j] = x;
  37.             }
  38.     int n;
  39.     cout << "Enter n = ";
  40.     cin >> n;
  41.     if (n > k)
  42.     {
  43.         cout << "Impossible";
  44.         exit(-1);
  45.     }
  46.     for (i = 0; i < n; i++)
  47.         out.write((char*)&a[i], sizeof(a[i]));
  48.     out.close();
  49.     ifstream in_bin("pret.bin", ios::binary);
  50.     bool s = false;
  51.     for (int i = 0; i < n; i++)
  52.     {
  53.         in_bin.read((char*)&x, sizeof(x));
  54.         if (x.age <= 45 && x.edu == 2 && x.exp >= 15 && x.dismiss == 0 && x.num_jobs <= 2)
  55.         {
  56.             cout << x.fio << x.age << endl;
  57.             s = true;
  58.         }
  59.     }
  60.     if (!s)
  61.         cout << "Not found";
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top