哪位帮帮我啊..c语言...

来源:百度知道 编辑:UC知道 时间:2024/07/02 06:24:04
#include <stdio.h>

#include <conio.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define OVERFLOW -2
#define INITSIZE 100
#define INCREAS 10
typedef int status;
typedef char SElemtype ;
typedef struct{
SElemtype *base;
SElemtype *top;
int stacksize;
}pstack;
status initpstack(pstack *s)
{s->base=(SElemtype *)malloc(INITSIZE*sizeof(SElemtype));
s->top=s->base;
s->stacksize=INITSIZE;
printf("Init finish!\n");
return OK;
}
status pstackempty(pstack *s)
{ return (s->top==s->base);
}
status pstackpush(pstack *s,SElemtype ch)
{if((s->top)-(s->base)>=(s->stacksize))
{s->base=(SElemtype *)realloc(s->base,(s->stacksize+INCREAS)*sizeof(SElemtype));
if(!s->base) exit(OVE

#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define OVERFLOW -2
#define INITSIZE 100
#define INCREAS 10
typedef int status;
typedef char SElemtype ;
typedef struct
{
SElemtype *base;
SElemtype *top;
int stacksize;
}pstack;
status initpstack(pstack *s)
{
s->base=(SElemtype *)malloc(INITSIZE*sizeof(SElemtype)); //malloc need to #include <stdlib.h>
s->top=s->base;
s->stacksize=INITSIZE;
printf("Init finish!\n");//printf need #include <stdio.h>
return OK;
}
status pstackempty(pstack *s)
{
return (s->top==s->base);
}
status pstackpush(pstack *s,SElemtype ch)
{
if((s->top)-(s->base)>=(s->stacksize))
{
s->base=(SElemtype *)realloc(s->