/*------------------------------------------------------------------------*
*
利用顺序栈解决栈的排序问题:按升序对一个栈进行排序,即最小元素位于栈顶。
最多只能使用一个额外的栈存放临时数据,并输出栈排序的过程
*
* ------------------------------------------------------------------------*/
#include <iostream>
#define ok 1
#define error 0
#define overflow -2
#define MaxSize 100
using namespace std;
typedef int SElemType;
typedef int status;
//定义
typedef struct
{
SElemType *base; //栈底指针
SElemType *top; //栈顶指针
int stacksize; //栈可用的最大容量
}SqStack;
//声明
status InitStack(SqStack &s);
status StackEmpty (SqStack s);
status Push (SqStack &s, SElemType e);
status Pop (SqStack &s, SElemType &e);
status PrintStack (SqStack s);
SElemType GetTop (SqStack s,SElemType &e);
status up_sort(SqStack &s, SqStack temp);
status DestroyStack (SqStack &s);
int main()
{
in
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交