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