数据结构之 顺序栈的操作
2013-09-26 23:32
183 查看
// 栈.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "malloc.h" #define maxSize 100 typedef struct { int data[maxSize]; int top; }SqStack; void push(SqStack &st,int x) { if(st.top==maxSize-1) return; st.top++; st.data[st.top]=x; } void pop(SqStack &st,int &x) { if(st.top==-1) return; x=st.data[st.top]; st.top--; return; } void show(SqStack &st) { if(st.top==-1) return; int x; while(st.top!=-1) { pop(st,x); printf("%d ",x); } } void initSqStack(SqStack &st) { st.top=-1; } int _tmain(int argc, _TCHAR* argv[]) { SqStack L; initSqStack(L); for(int i=1;i<=10;i++) push(L,i); show(L); }
以上代码实现了顺序栈的各种操作
相关文章推荐
- 数据结构--顺序表操作(C++版)
- 数据结构-顺序表的基本操作
- 顺序表的简单操作(数据结构)
- 数据结构-循环顺序队列的基本操作
- 数据结构 - 顺序表的基本操作(C语言)
- 数据结构-线性表的顺序存储实现及各种操作代码
- 数据结构 顺序表的操作(源代码)
- 数据结构之顺序表的操作
- 进击的数据结构之六队列的基本操作-顺序结构
- 《数据结构》严蔚敏版(java解)——第三章 栈和队列03 顺序队列操作
- c语言版数据结构(奇迹冬瓜)-串(定长顺序存储各项操作)
- 数据结构学习(一)——顺序表的操作
- 【数据结构】采用数组的形式实现顺序表的建立、插入、删除等操作
- 数据结构 顺序栈的基本操作
- 【数据结构】用C++实现顺序表的各种操作(包括头删,尾删,插入,逆序,摧毁,清空等等)
- 数据结构:顺序表的操作
- C语言版数据结构中顺序表的基本操作定义和初始化
- 数据结构—线性表之顺序表的操作
- 数据结构-顺序串的基本操作
- 数据结构初学者顺序表的操作(精简版)