Write a program that will accept a list of integer number. The odd numbers will be stored into a queue call ODDQUEUE and the even number will be stored in different queue call EVENQUEUE.
this is under subject data structure and algorithm so the code might be almost same to c++ but it is different in it structure
1
Expert's answer
2011-10-07T08:05:43-0400
#include <iostream> #include <queue>
using namespace std;
int main() { queue<int> EVENQUEUE, ODDQUEUE;
int n; cout << "Total number of items: "; cin >> n;
int q, i; for (i=0; i<n; i++) { cout << "a[" << i << "]= "; cin >> q; if (q % 2) { EVENQUEUE.push(q); } else { ODDQUEUE.push(q); }; }; return 0; };
Comments
Leave a comment