Queues C++
Not what you're looking for?
Consider the following statements:
stackType<int> stack;
queueType<int> queue;
int x;
Suppose the input is:
15 28 14 22 64 35 19 32 7 11 13 30 -999
Show what is output by the following segment of code.
stack.initializeStack();
queue.initializeQueue();
stack.push(0);
queue.addQueue(0);
cin>>x;
while(x != -999)
{
switch(x % 4)
{
case 0: stack.push(x);
break;
case 1: if(!stack.isEmptyStack())
{
cout<<"Stack Elment = "<<stack.top()<<endl;
stack.pop();
}
else
cout<<"Sorry, the stack is empty."<<endl;
break;
case 2: queue.addQueue(x);
break;
case 3: if(!queue.isEmptyQueue())
{
cout<<"Queue Element = "<<queue.front()<<endl;
queue.deleteQueue();
}
else
cout<<"Sorry, the queue is empty."<<endl;
break;
}//end switch
cin>>x;
}//end while
cout<<"Stack Elements: ";
while(!stack.isEmptyStack())
{
cout<<stack.top()<<" ";
stack.pop();
}
cout<<endl;
cout<<"Queue Elements: ";
while(!queue.isEmptyQueue();
{
cout<<queue.front()<<" ";
queue.deleteQueue();
}
cout<<endl;
See attached file for full problem description.
Purchase this Solution
Solution Summary
Queues C++ are highlighted.
Purchase this Solution
Free BrainMass Quizzes
Excel Introductory Quiz
This quiz tests your knowledge of basics of MS-Excel.
C# variables and classes
This quiz contains questions about C# classes and variables.
Javscript Basics
Quiz on basics of javascript programming language.
Basic Networking Questions
This quiz consists of some basic networking questions.
Basic Computer Terms
We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.