Seal_of_approval

PrS&Q

Jun 30th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <stack>
  3. #include <queue>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. int main (void)
  9. {
  10.     ifstream in ("input.txt");
  11.     ofstream out ("output.txt");
  12.  
  13.     queue <int> q;
  14.     stack <int> s;
  15.    
  16.     int a;
  17.     while (in >> a)
  18.     {
  19.         q.push(a);
  20.     }
  21.  
  22.     while (!q.empty())
  23.     {
  24.         a = q.front();
  25.         q.pop();
  26.         if (a % 2 != 0)
  27.         {
  28.             s.push(a);
  29.         }
  30.     }
  31.  
  32.     while (!s.empty())
  33.     {
  34.         a = s.top();
  35.         s.pop();
  36.         if (a % 3 == 0)
  37.             out << a << " ";
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment