Answer to Question #4266 in C++ for Nisa

Question #4266
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;
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS