进出栈
来源:互联网 发布:福建 知乎 编辑:程序博客网 时间:2024/04/29 18:57
进出栈代码如下
#include<stdio.h>#include<stdlib.h>#define M 100typedef struct { int data[M]; int top;}SqStack; //初始化 int InitSqStack(SqStack *S){ S->top=-1; return 1;}//压栈int PushSqStack(SqStack *S,int e){ if(S->top==M-1) { return 0; } S->top++; S->data[S->top]=e; return 1;} //出栈int PopSqStack(SqStack *S,int *e){ if(S->top==-1) { return 0; } *e=S->data[S->top--]; return 1;}int main(){ SqStack S; int e,j; InitSqStack(&S); //以下是测试 PushSqStack(&S,4); PushSqStack(&S,8); PushSqStack(&S,10); PushSqStack(&S,78); PushSqStack(&S,49); for(j=0;j<M;j++) { if(PopSqStack(&S,&e)){ printf("%d ",e); } } printf("\n"); return 0;}
阅读全文
0 0
- 进出栈
- 进出栈
- 简单进出栈程序
- STL栈 - 火车进出栈
- 栈的进出序列问题
- 火车进出站问题---栈
- 序列是否能够由进出栈得到
- 卡特兰数(进出栈情况)
- HDU-1022 火车进出站问题【栈】
- 栈与队列(一)进出栈(含二转十进制栈应用)
- 机试准备 进出栈的迭代 解法
- 数据结构 ——进出栈操作的算法
- fragment的学习(2)传递参数和进出栈
- 全排列、判断栈序、火车进出站
- 进出异常
- 进出登记
- 进出队列
- Fastjson序列化map时,保留map的进出栈顺序的方法
- 【Linux命令】scp传输文件
- 编程序找出1000之内的所有完数,并按下面格式输出其因子:6 its factors are 1,2,3
- JAVA知识点整理第六部分——线程
- Unity3D-在移动端显示Debug信息
- ubuntu apach2 配置
- 进出栈
- Remove Duplicates from Sorted Arrays
- 挑战程序设计竞赛 算法和数据结构 第18章 数论
- 工作日志的坑位
- 自己编写Android Studio插件 别停留在用的程度了
- jsp中使用EL表达式,出现Uncaught SyntaxError: Unexpected number错误
- pandas学习笔记5—DataFrame数据筛选loc,iloc,ix,at,iat
- PHP操作MongoDB
- python运算符