The Sqstack for Sequential stack (Continuous updates) | Data
程序员文章站
2022-04-25 19:30:28
...
The Sqstack for Sequential stack | Data
The code in Data book (5th Edition) from the 81 page to 82 page
Continuous updates
#define MaxSize 50
typedef int ElemType;
typedef struct{
ElemType data[MaxSize];
int top;
} SqStack;
//Initialization SqStack
void InitStack(SqStack *&s){
s=(SqStack *)malloc(sizeof(SqStack));
s->top=-1;
}
//Destroyed Sqstack
void DestroyStack(SqStack *&s){
free(s);
}
//Determine if the stack is empty
bool StackEmpty(SqStack *s){
return(s->top==-1);
}
//Into the stack
bool Push(SqStack *&s, ElemType e){
if (s->top==MaxSize-1){
return false;
}
s->top++;
s->data[s->top]=e;
return true;
}
//Out stack
bool Pop(SqStack *&s, ElemType &e){
if (s->top==-1)
return false;
e=s->data[s->top];
s->top--;
return true;
}
//Top element of the stack
bool GetTop(SqStack *s, ElemType &e){
if (s->top==-1)
return false;
e=s->data[s->top];
return true;
}
如有侵权,请联系作者删除
上一篇: fetch异常状态处理
下一篇: fetch
推荐阅读
-
mysql load data infile 命令的数据导入
-
Oracle X$ tables – Part 1 – Where do they get their data f
-
HTML data属性_html/css_WEB-ITnose
-
Spring Data Solr 查询方法
-
mysql5.5数据库data目录迁移方法详解_MySQL
-
Spring Data Jpa+SpringMVC+Jquery.pagination.js实现分页示例
-
php提示Failed to write session data错误的解决方法_php技巧
-
springboot使用spring-data-jpa操作MySQL数据库
-
详解log4j-over-slf4j与slf4j-log4j12共存stack overflow异常分析
-
Spring Data JPA 实现多表关联查询的示例代码