stack的数组实现
来源:互联网 发布:mac玩lol国服 编辑:程序博客网 时间:2024/06/05 18:59
//stack的数组实现(方法类似于类的定义)
//1:实现栈的数据定义
//2:实现操作方法的定义push pop empty full top(并不需要,因为stack[top]就是top)
//1:实现栈的数据定义
//2:实现操作方法的定义push pop empty full top(并不需要,因为stack[top]就是top)
//ps:在采用数组实现栈时,数组0下标对应的是栈底,top下标对应的是栈顶
#include <stdio.h>#define MAXSIZE 100struct node{int a;char b;};//1的实现struct stack{node n[MAXSIZE];//这里定义n[0]为栈底int top;};//2的实现bool emptyStack(stack *s) { if(s->top==-1) return true; return false; }bool fullStack(stack *s){if(s->top==MAXSIZE-1)return true;return false;}bool pushStack(stack *s ,node p){if(fullStack(s))return 0;s->top++;s->n[s->top]=p;return 1;}bool popStack(stack *s){if(emptyStack(s))return false;s->top--;return true;}void main(){stack s;s.top=-1;node a={1,'f'};node b={2,'e'};node c={3,'g'};pushStack(&s,a);pushStack(&s,b);pushStack(&s,c);printf("%2d\n",s.n[0].a);printf("%2d\n",s.n[1].a);printf("%2d\n",s.n[s.top].a);popStack(&s);printf("%2d\n",s.n[s.top].a);}
- stack的数组实现
- 数据结构栈stack的动态数组实现
- 静态数组实现的Stack类
- 用数组实现Stack
- 数组实现stack
- 数组实现stack
- 动态数组实现stack
- 动态数组的Stack类模板的实现
- 栈 stack 用数组实现
- [数据结构]Stack(数组)实现
- js用数组实现Stack
- Stack类模板的动态数组实现(基本功能)
- 【算法导论学习-17】stack的数组实现
- 算法导论------------栈(stack)简单的数组实现
- 创建自己的Stack底层使用数组来实现
- stack的数组实现(结构体封装版)
- 算法学习之路(2):stack的数组实现
- 动态数组实现的Stack类(过渡版)
- uva10048 - Audiophobia()
- 数据挖掘(五):聚类
- VS2010拖Web用户控件时卡死 解决方案
- (4M+2)阶魔方阵算法
- [Oracle] Oracle 入门命令
- stack的数组实现
- Scrum可能被挑战的方面
- jquery 读取 xml 并显示
- 异步下载image
- olap和oltp系统区别
- Cable Modem Initialization and Reinitialization
- 2013年5月23日(7-9ddraw裁剪器)
- Tiny210V2(S5PV210)的U-boot分析
- 黑马程序员_String类和StringBuffer