#include<stdio.h>
#include<stdlib.h>
//用链表实现栈
typedef struct Node {
int data;
struct Node *next;
} node; int IsEmpty(node *p) {
return p->next==NULL;
} node *CreateStack() {
node *p=(node*)malloc(sizeof(node));
p->next=NULL;
return p;
} node *Push(node *p,int x) {
node *TmpCell=(node*)malloc(sizeof(node));
TmpCell->data=x;
TmpCell->next=p->next;
p->next=TmpCell;
return p;
} void Pop(node *p) {
node *cell;
if(p->next==NULL) {
printf("error,-1");
} else {
cell=p->next;
p->next=cell->next;
free(cell);
}
} void display(node *p) {
node *temp=p;
while(temp->next) {
printf("%d",temp->next->data);
temp=temp->next;
}
printf("%c",'\n');
} main() {
node *p=CreateStack();
Push(p,);
Push(p,);
Push(p,);
Push(p,);
display(p);
Pop(p);
display(p);
Pop(p);
display(p);
}

最新文章

  1. MySQL5.0安装图解
  2. 【转载】RMAN备份保留策略设置相关命令
  3. Use getopt() &amp; getopt_long() to Parse Arguments
  4. Javascript输出表格
  5. 利用Shell命令获取IP地址
  6. C与C++存储空间布局
  7. DrawDibDraw函数的使用方法
  8. iOS真机测试种可能遇到的问题
  9. zabbix-web界面图形中文乱码解决方法
  10. 开源libusb驱动的libwdi驱动安装API库和zadig.exe安装UI应用程序的编译和调试
  11. web page diagnostics
  12. org.apache.commons.lang下的工具类
  13. 微信小程序弹出和隐藏遮罩层动画以及五星评分
  14. 【java】-- 多线程之间实现通讯
  15. storcli 简易使用介绍
  16. Spark之GraphX的Graph_scala学习
  17. lightoj 1341 Aladdin and the Flying Carpet(算术基本定理)题解
  18. Android SDK的安装与环境配置
  19. Android Eclipse 开发环境搭建
  20. NOIP Mayan游戏

热门文章

  1. 使用UISegementControl实现简易Tomcat程序
  2. WPF中PasswordBox控件的Password属性的数据绑定
  3. C# .NET数据库操作
  4. vue 使用jquery (全局)
  5. 配置mysql 及 设置密码
  6. Information Centric Networking Based Service Centric Networking
  7. [Unity3D]Unity3D游戏开发Lua随着游戏的债券(在)
  8. ASP.NET Core 中间件 - ASP.NET Core 基础教程 - 简单教程,简单编程
  9. wpf Storyboard 不存在可解析名称“ ”的适用名称领域 No applicable name scope exists to resolve the name
  10. CSS position财产