麻烦简述以下算法的功能(栈和队列的元素类型均为int)

(1)void algo3(Queue &Q){
Stack S; int d;
InitStack(S);
while(!QueueEmpty(Q)){
DeQueue(Q,d);
Push(S,d);
}
while(!StackEmpty(S)){
Pop(S,d);
EnQueue(Q,d);
}
}
(2) void Demo1( Stack *S, int m)
{ Stack T; int i;
   InitStack (T);
   while (! StackEmpty(S))
   if(( i=Pop(S)) !=m) Push( T,i);
   while (! StackEmpty(T))
   {
   i=Pop(T); Push(S,i);
   }
   }
谢谢 啦 详细一点点 最好了

人到中年有点甜
浏览 332回答 1
1回答

一只甜甜圈

(1)将队列中的元素顺序颠倒,比如原队列ABCD,执行后DCBA(2)将栈中的m元素移除,比如栈ABCDBCDC,m=B,执行后ACDCDC
打开App,查看更多内容
随时随地看视频慕课网APP