C++ 作业
来源:互联网 发布:淘宝客高佣金采集软件 编辑:程序博客网 时间:2024/06/03 23:43
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>#include <stack>using namespace std;const int INF = 1E9 + 7;class Stack {private : struct node { int key; struct node * pre; struct node * nexT; }*tail; int length;public: Stack () { tail = NULL; length = 0; } ~Stack () { delete tail; } void push (int x); int pop (); int top (); inline int size () {return length;} inline bool empty () {return length == 0;}};void Stack:: push (int x) { node * temp; temp = new (node); tail -> nexT = temp; temp -> pre = tail; tail = temp; temp -> key = x; tail -> nexT = NULL;}int Stack:: top () { if (empty()) return INF; return tail -> key;}int Stack:: pop() { if (empty()) return INF; if (size () == 1) { tail = NULL; return -INF; } node * temp = tail; tail = tail -> pre; tail -> nexT = NULL; int ans = temp -> key; delete temp; return ans;}int main () { return 0;}
阅读全文
0 0
- c 作业
- c作业
- C作业
- c作业
- c作业
- c作业
- c作业
- c作业
- 【C语言】【unix c】作业 前台作业和后台作业
- C语言期中作业
- C语言期末作业
- C基础作业
- C语言小作业
- c语言作业2
- C语言小作业
- 第一次C程序设计作业
- 第一次C程序设计作业
- 第一次C程序设计作业
- 17.11.12,web学习第二天,还有一年,努力吧青年!
- TCP拥塞控制
- 为何键盘上的字母排序和字母表不同
- 3.2 求值的环境模型
- 【软考学习】设计模式——抽象工厂
- C++ 作业
- Tensorflow学习(1)之安装
- centos安装java web服务器环境java8+tomcat8+mysql5.7
- 英语单词
- Scrapy学习笔记(6)---scrapy shell
- 一.PHP几种加密形式
- JAVA基础复习-反射
- C和指针之数组编程练习3(判断矩阵是否为单位矩阵)
- 使用yum来下载RPM包而不进行安装