Advertisement
Guest User

14 Laba Moiseeva - Queue

a guest
Aug 27th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <iostream>
  4. #include <string.h>
  5. #include <queue>
  6.  
  7. using namespace std;
  8.  
  9. struct Workers {
  10.     char fio[50];
  11.     char date_bir[50];
  12.     char home_a_dress[50];
  13.     char speshial[50];
  14.     int stag_rabot;
  15. };
  16.  
  17. void debug() {
  18.     cin.clear();
  19.     while(cin.get() != '\n');
  20.     return;
  21. }
  22.  
  23. int main() {
  24.     queue<Workers> in;
  25.     queue<Workers> out;
  26.     Workers tmp;
  27.     for(int i = 0; i < 2; i++) {
  28.         cout << "fio" << endl;
  29.         cin.getline(tmp.fio, 50);
  30.  
  31.         cout << "date_bir" << endl;
  32.         cin.getline(tmp.date_bir, 50);
  33.  
  34.         cout << "home_a_dress" << endl;
  35.         cin.getline(tmp.home_a_dress, 50);
  36.  
  37.         cout << "speshial" << endl;
  38.         cin.getline(tmp.speshial, 50);
  39.  
  40.         cout << "stag_rabot" << endl;
  41.         while(!scanf("%d", &tmp.stag_rabot)) {
  42.             debug();
  43.             cout << "Vvedite shislo" << endl;
  44.         }
  45.  
  46.         cout << endl;
  47.         in.push(tmp);
  48.         debug();
  49.     }
  50.  
  51.     printf("|%20s|%20s|%20s|%25s|%12s|\n\n",
  52.            "fio",
  53.            "date_bir",
  54.            "home_a_dress",
  55.            "speshial",
  56.            "stag_rabot");
  57.  
  58.  
  59.     while(!in.empty()) {
  60.         tmp = in.front();
  61.         printf("|%20s|%20s|%20s|%25s|%12d|\n",
  62.                tmp.fio,
  63.                tmp.date_bir,
  64.                tmp.home_a_dress,
  65.                tmp.speshial,
  66.                tmp.stag_rabot);
  67.         if((tmp.stag_rabot > 10) && (strcmp(tmp.speshial, "ingener-sistemotechnic") == 0)) {
  68.             out.push(tmp);
  69.         }
  70.         in.pop();
  71.     }
  72.  
  73.     printf("\n\n|%20s|%12s|\n",
  74.            "fio",
  75.            "stag_rabot");
  76.  
  77.     while(!out.empty()) {
  78.         tmp = out.front();
  79.         printf("|%20s|%12d|\n",
  80.                tmp.fio,
  81.                tmp.stag_rabot);
  82.         out.pop();
  83.     }
  84.  
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement