堆栈的相关操作_链式存储
来源:互联网 发布:中教数据库 评职称 编辑:程序博客网 时间:2024/06/05 20:19
#include <bits/stdc++.h>
typedef struct node *pointer;
struct node
{
int Data;
pointer next;
};
typedef pointer stack;
stack Push( stack S, int X ) /* 将元素X压入堆栈S */
{
pointer q;
q = (pointer)malloc(sizeof(struct node));
q->Data = X;
q->next = S->next;
S->next = q;
return S;
}
int Pop(stack S) /* 删除并返回堆栈S的栈顶元素 */
{
pointer first;
int top;
first = S->next;
top = first->Data;
S->next = first->next;
free(first);
return top;
}
stack Createstack() /* 构建一个堆栈的头结点,返回该结点指针 */
{
stack S;
S = (stack)malloc(sizeof(struct node));
S->next = NULL;
return S;
}
int main()
{
return 0;
}
typedef struct node *pointer;
struct node
{
int Data;
pointer next;
};
typedef pointer stack;
stack Push( stack S, int X ) /* 将元素X压入堆栈S */
{
pointer q;
q = (pointer)malloc(sizeof(struct node));
q->Data = X;
q->next = S->next;
S->next = q;
return S;
}
int Pop(stack S) /* 删除并返回堆栈S的栈顶元素 */
{
pointer first;
int top;
first = S->next;
top = first->Data;
S->next = first->next;
free(first);
return top;
}
stack Createstack() /* 构建一个堆栈的头结点,返回该结点指针 */
{
stack S;
S = (stack)malloc(sizeof(struct node));
S->next = NULL;
return S;
}
int main()
{
return 0;
}
阅读全文
0 0
- 堆栈的相关操作_链式存储
- 队列的链式存储相关操作
- 堆栈的定义与操作(链式存储)
- c 堆栈的链式存储
- 堆栈的链式存储实现
- 线性表的链式存储及相关操作 C语言版
- 线性表的链式存储及相关操作
- 数据结构之堆栈的链式存储
- 数据结构:堆栈的链式存储实现
- 堆栈的链式存储(链表)
- 2.2.3 堆栈的链式存储实现
- 数据结构_线性表_链式存储_单链表 的基本操作
- 数据结构_线性表_链式存储_单向循环链表的基本操作
- 数据结构_线性表_链式存储_双向循环链表的基本操作
- 队列的相关操作_顺序存储
- 堆栈--链式存储
- 堆栈的相关操作
- 堆栈的链式建立和操作
- ubuntu16.04.2安装mysql
- 安装Dubbo注册中心(Zookeeper-3.4.6)
- 打渔晒网问题(难度:1颗星)
- Android应用名与activity窗口标题名字如何做到不一样
- 物理机上不能通过Navicat连接虚拟机上安装的mysql解决办法
- 堆栈的相关操作_链式存储
- 数学建模与数据科学简要(Mathematical model&Data science)
- 移动端IOS使用EasyAr实现非unity(unity)案例介绍
- IP
- idea快捷键
- case when
- Qt之高级网络操作(HTTP/FTP快速上手)
- 24、二叉树中和为某一值的路径
- 树状数组,区间求和