经典的数据结构——栈
来源:互联网 发布:背四级单词软件 编辑:程序博客网 时间:2024/06/06 02:32
很经典的数据结构,在VS2012上,可运行
// test2.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>using namespace std;struct Node{int data; /*值域*/struct Node *next; /*链接指针*/};struct stack{struct Node *top; /*队首指针*/};void initstack(stack *p){p->top = NULL;}void popstack(stack *p){Node * temp = p->top;p->top = p->top->next;temp->next = NULL;delete temp;}void pushstack(stack *p, int x){Node * temp = new Node;temp->data = x;temp->next = p->top;p->top = temp;}int _tmain(int argc, _TCHAR* argv[]){stack sp;initstack(&sp);for (int i=0; i<=9; ++i){pushstack(&sp, i);}popstack(&sp);cout << sp.top->data << endl;system("pause");return 0;}
---------------
0 0
- 经典的数据结构——栈
- 经典的数据结构——队列
- 经典的数据结构——循环队列
- 经典数据结构--数组实现的栈
- 很经典的数据结构
- 数据结构经典问题——出栈顺序
- 《奥赛经典——数据结构篇》 3.1栈
- 数据结构——经典排序算法
- 数据结构经典面试题——概念
- 《算法经典》——第六章 数据结构
- 数据结构的非经典解法
- 小猪的数据结构辅助教程——2.5 经典例子:约瑟夫问题的解决
- 经典算法与数据结构的c++实现——带头结点的单链表
- 经典算法与数据结构的c++实现——冒泡排序
- 经典算法与数据结构的c++实现——插入排序
- 经典算法与数据结构的c++实现——shell排序算法
- 经典算法与数据结构的c++实现——直接选择排序
- 经典算法与数据结构的c++实现——快速排序
- 在mybatis调用mysql的函数
- Nginx发布1.9.0版本,新增支持TCP代理和负载均衡的stream模块
- java抽象类和接口
- 开发者都应该使用的10个C++11特性
- mysql日期存储为int,mybatis做ORM映射与java.util.Date的转换问题
- 经典的数据结构——栈
- UE4示例项目学习:用Blueprint来创建一个可操作角色(二) 动画蒙太奇篇(Animation Montage)
- 【规则引擎连载3】 WebSphere ILOG JRules 开发——新建一个规则项目
- oracle日期字段只取日期不要时间
- ubuntu16.04下安装scrapy框架
- 打造靓白裸妆人像(修补工具和色相/饱和度)
- SPARK里的reduce(),fold(),以及aggregate()
- CC2530 zigbee RS485通讯
- android国际化(多语言)