Hello;
steps are correct;
there is no error ;
but when running the prog. this what apear :(its in attach)
this is my code and the main:
template<class Type>
void sortQueue(queueType <Type> & q1)
{
queueType <Type> q2;
queueType <Type> qresult;
Type min=q1.front();
q2.addQueue(min);
while(!q1.isEmptyQueue())
{
q1.deleteQueue();
while(!q1.isEmptyQueue())
{
if(min>q1.front())
{min=q1.front();
q2.addQueue(q1.front());
q1.deleteQueue();
}
else
{ q2.addQueue(q1.front());
q1.deleteQueue();
}
qresult.addQueue(min);
while(!q2.isEmptyQueue())
{
if(q2.front()==min)
q2.deleteQueue();
else
{
q1.addQueue(q2.front());
q2.deleteQueue();
}
}
min=q1.front();
q2.addQueue(min);
}
}
}
int main()
{
queueType <int> myQ ;
initializeQueue();
myQ.addQueue(15);
myQ.addQueue(9);
myQ.addQueue(4);
myQ.addQueue(3);
myQ.addQueue(1);
myQ.addQueue(2);
sortQueue(myQ);
while(!myQ.isEmptyQueue())
{
cout<<myQ.front()<<" ";
myQ.deleteQueue();
}
return 0;
}