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();

 

}
相关推荐
_Lzk666888_1 天前
洛谷用户2002780求关注
c++·其他
maozexijr1 天前
Rabbit MQ中@Exchange(durable = “true“) 和 @Queue(durable = “true“) 有什么区别
开发语言·后端·ruby
深圳佛手1 天前
使用java,怎么样高效地读取一个大文件(10g以上)?
java·开发语言
xiaolyuh1231 天前
【XXL-JOB】 GLUE模式 底层实现原理
java·开发语言·前端·python·xxl-job
源码获取_wx:Fegn08951 天前
基于 vue智慧养老院系统
开发语言·前端·javascript·vue.js·spring boot·后端·课程设计
ohoy1 天前
RedisTemplate 使用之Zset
java·开发语言·redis
Learner1 天前
Python数据类型(三):列表和元组
开发语言·python
leluckys1 天前
AI- 一种快速实现MCP服务的方法
开发语言·python
qq_401700411 天前
C语言 条件编译宏
c语言·开发语言
写代码的【黑咖啡】1 天前
探索 Python 中的 Vaex:高效处理大规模数据的新选择
开发语言·python