📄 wex5_8.cpp
字号:
#include <iostream.h>
#pragma hdrstop
typedef int DataType;
#include "astack.h"
void Ques8(Stack& S, int n)
{
Stack Q;
int i;
while(!S.StackEmpty())
{
i = S.Pop();
if (i != n)
Q.Push(i);
}
while(!Q.StackEmpty())
{
i = Q.Pop();
S.Push(i);
}
}
void main(void)
{
Stack S;
for(int i=1;i <= 5;i++)
S.Push(i);
S.Push(4);
S.Push(4);
S.Push(7);
S.Push(1);
Ques8(S,4);
while (!S.StackEmpty())
cout << S.Pop() << " ";
cout << endl;
}
/*
<Run>
1 7 5 3 2 1
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -