awsmpshk

Очередь. Задача №7

Apr 20th, 2020
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <string>
  2. #include <fstream>
  3. #include <queue>
  4.  
  5. using namespace std;
  6.  
  7. struct Employee
  8. {
  9.   string F, I, O, gender;
  10.   int age, sallary;
  11.   void showInfo(ofstream& out)
  12.   {
  13.     out << F << " " << I << " " << O << " " << gender << " " << age << " " << sallary << endl;
  14.   }
  15. };
  16.  
  17. void printQueue(ofstream& out, queue<Employee> que)
  18. {
  19.   while (que.size() != 0)
  20.   {
  21.     que.front().showInfo(out);
  22.     que.pop();
  23.   }
  24. }
  25.  
  26. int main()
  27. {
  28.   ifstream in("input.txt");
  29.   ofstream out("output.txt");
  30.  
  31.   int n;
  32.   in >> n;
  33.   queue<Employee> less10000;
  34.   queue<Employee> more10000;
  35.  
  36.   for (int i = 0; i < n; ++i)
  37.   {
  38.     Employee obj;
  39.     in >> obj.F >> obj.I >> obj.O >> obj.gender >> obj.age >> obj.sallary;
  40.     if (obj.sallary < 10000) less10000.push(obj);
  41.     else more10000.push(obj);
  42.   }
  43.  
  44.   printQueue(out, less10000);
  45.   printQueue(out, more10000);
  46.  
  47.   in.close();
  48.   out.close();
  49.   return 0;
  50. }
RAW Paste Data Copied