栈的基本操作
来源:互联网 发布:号码排列组合软件 编辑:程序博客网 时间:2024/06/06 17:25
#include<stdio.h>#include<stdlib.h>#define length 100#define add 10typedef struct size{int *top;int *basic;int stacksize;}Stacks;void InitStacks(Stacks &S){S.basic=(int *)malloc(length * sizeof(int));if(!S.basic){printf("Creat erro!");exit(0);}S.top=S.basic;S.stacksize=length;printf("Creat succeed!\n");}void PushStacks(Stacks &S,int n){if(S.top-S.basic>=length){S.basic = (int *)realloc(S.basic,(S.stacksize+add)*sizeof(int));if(!S.basic){printf("add failed!\n");exit(0);}S.stacksize=S.stacksize+add;S.top=S.basic+S.stacksize;}*S.top=n;S.top++;}int EmptyStacks(Stacks S){if(S.top==S.basic){printf("the Stacks is Empty!\n");return 0;}return 1;}void PopStacks(Stacks S){if(!EmptyStacks(S))exit(0);while(S.top!=S.basic){S.top--;printf("%d ",*S.top);}putchar('\n');}int main(){Stacks S;return 0;}
0 0
- 栈的基本操作
- 栈的基本操作
- 栈 的基本操作。
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- 栈的基本操作
- Linux系统编程获取系统的CPU资源
- Java—— 随机抽取扑克牌游戏
- Python自动单元测试框架
- 2012素数判定
- 年终总结之那些年,我们用过的工具
- 栈的基本操作
- java 键盘事件
- 欢迎使用CSDN-markdown编辑器
- xib与nib的区别
- 集线器、交换机、路由器、网关
- 练习3.2,3.3,3.4
- 二十三种设计模式之结构型模式之装饰模式
- Windows 下编译 taglib
- java解析json数据