Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stack>
- #include <queue>
- #include <fstream>
- using namespace std;
- int main (void)
- {
- ifstream in ("input.txt");
- ofstream out ("output.txt");
- queue <int> q;
- stack <int> s;
- int a;
- while (in >> a)
- {
- q.push(a);
- }
- while (!q.empty())
- {
- a = q.front();
- q.pop();
- if (a % 2 != 0)
- {
- s.push(a);
- }
- }
- while (!s.empty())
- {
- a = s.top();
- s.pop();
- if (a % 3 == 0)
- out << a << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment