stl-stack

目录

[创建stack name](#创建stack name)

访问。top()

添加元素。push()

删除元素。pop()

判空。empty()

元素个数。size()

用途​编辑

代码


创建stack<tp> name

访问。top()

和queue or priority q类似,这种数据结构形的,访问都不那么自由

添加元素。push()

有些不解哦

哦,又是那个错误,你删着删着,stk.size也在变小。。

删除元素。pop()

判空。empty()

元素个数。size()

用途

代码

cpp 复制代码
#include <cstdio>
#include <queue>
#include <vector> 
#include <set> 
#include <string>
#include <iostream>
#include <map>
#include <stack>
using namespace std;
stack<int> stk;

int main()
{
//	fruit
stk.push(3);
stk.push(1);  
stk.push(3);
stk.push(8); 
int n=stk.size();
for(int i=0;i<n;i++)
cout<<stk.top(),stk.pop();

 

}
相关推荐
谭欣辰2 分钟前
C++ 哈希表详解
c++·算法·哈希算法·散列表
AKA__Zas2 分钟前
初识多线程(初初识)
java·服务器·开发语言·学习方法
zhangrelay7 分钟前
三分钟云课实践速通--概率统计--python版
linux·开发语言·笔记·python·学习·ubuntu
blasit7 分钟前
Qt C++ http服务器安全登录token生成管理
c++·后端·qt
云栖梦泽13 分钟前
Linux内核与驱动:GPIO设备树与SPI设备树的区别
linux·运维·c++·嵌入式硬件
张赐荣13 分钟前
深入详解在 Python 中用 ctypes 调用 Windows API 清空回收站
开发语言·windows·python
南境十里·墨染春水16 分钟前
C++笔记——STL list
c++·笔记·list
彷徨而立17 分钟前
【C/C++】在头文件中定义全局变量的方法
c语言·开发语言·c++
脱氧核糖核酸__19 分钟前
LeetCode热题100——206.反转链表(迭代法)
c++·leetcode·链表