栈的基本操作
一、进制转换
二、括号匹配
三、行编辑
Stack_Head.h
#include <stdio.h>
#include <stdlib.h>
#define STACKINCREAMENT 10
#define STACK_INIT_SIZE 100
#define OK 1
#define ERROR 0
typedef int status;
typedef char SElemtype;
typedef struct
{
SElemtype *base;
SElemtype *top;
status stacksize;
}sqstack;
status Init(sqstack *S)
{
S->base = (SElemtype *)malloc(STACK_INIT_SIZE * sizeof(SElemtype));
if (!S->base)
exit(0);
S->top = S->base;
S->stacksize = STACK_INIT_SIZE;
return OK;
}
status Gettop(sqstack *S, SElemtype e)
{
if (S->top == S->base)
return ERROR;
e = *(S->top - 1);
return OK;
}
status push(sqstack *S, SElemtype e)
{
if (S->top - S->base >= S->stacksize)
{
S->base = (SElemtype *)realloc(S->base, (