Im trying to implement the Even or Odd numbers in different stacks & queues. Here is my code:
How I can display my Stack & Queue? How I can separate in Odd or Even in any queue?
#include <iostream>
#include <stack>
#include <queue>
using namespace std;
int main()
{
stack <int> s1;
queue <int> q1;
int num[10]={0};
for(int i = 0; i < 10; i++)
{
cout << "Enter Number " << i << ": ";
cin >> num[i];
s1.push(num[i]);
}
int s2;
int q2;
cout << "In Stack" << "\t" << "In Queue" << endl;
while(!q1.empty())
{
for(int i = 0; i <10; i++)
{
if(num[i]%2 == 0)
{
s2 = s1.top();
s1.pop();
}
else
{
q2 = q1.front();
q1.pop();
}
}
cout << s2 << "\t\t" << q2 << endl;
}
return 0;
}