为了账号安全,请及时绑定邮箱和手机立即绑定

下面代码设定“操作数”、"操作符”的栈的抽象数据类型的设计的具体节点?

下面代码设定“操作数”、"操作符”的栈的抽象数据类型的设计的具体节点?

C
Devil10 2016-12-27 12:39:14
只要操作数和操作符的具体节点的列举谢谢!typedef struct{ float *base;      float *top;      int stacksize; }SqStack_f;typedef struct{  char *base;  char *top;  int stacksize; }SqStack_c;void InitStack_f(SqStack_f *s){  s->base=(float *)malloc(TTACK_INIT_SIZE*sizeof(float));  if(!s->base)   exit(1);  s->top=s->base; s->stacksize=TTACK_INIT_SIZE; }void InitStack_c(SqStack_c *s) {  s->base=(char *)malloc(TTACK_INIT_SIZE*sizeof(char)); if(!s->base)   exit(1);  s->top=s->base;  s->stacksize=TTACK_INIT_SIZE; }void GetTop_f(SqStack_f *s,float *e) {  if(s->top==s->base)  {   printf("ERROR!\n");   exit(1);  }  *e=*(s->top-1); } void GetTop_c(SqStack_c *s,char *e) {  if(s->top==s->base)  {   printf("ERROR!\n");   exit(1);  }  *e=*(s->top-1); } void Push_f(SqStack_f *s,float e)  {  if(s->top-s->base>=s->stacksize)  {       s->base=(float *)realloc(s->base,(s->stacksize+STACKINCREMENT)*sizeof(float));       if(!s->base)   {       printf("OVERFLOW!\n");       exit(1);   }       s->top=s->base+s->stacksize;       s->stacksize+=STACKINCREMENT;  }      *s->top++=e;} void Push_c(SqStack_c *s,char e) {  if(s->top-s->base>=s->stacksize)  {   s->base=(char *)realloc(s->base,(s->stacksize+STACKINCREMENT)*sizeof(char));   if(!s->base)   {   printf("OVERFLOW!\n");    exit(1);   }  s->top=s->base+s->stacksize;   s->stacksize+=STACKINCREMENT;  }  *s->top++=e; }
查看完整描述

2 回答

?
Devil10

TA贡献2条经验 获得超0个赞

这上面两个提问和回答是一起的,求大神指点!

查看完整回答
反对 回复 2016-12-27
  • 2 回答
  • 0 关注
  • 940 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信