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 小时前
03 函数定义和调用
开发语言·python
I_belong_to_jesus2 小时前
C++关于分支预测的优化1
开发语言·c++·算法
承渊政道3 小时前
【Python编程—从入门到实践】(记分与闯关:用Python+Pygame,打造越战越精彩的太空大战!)
开发语言·python·pycharm·游戏程序·pygame
爱学习的程序媛3 小时前
Python常用框架梳理
开发语言·后端·python·ai·web·后端框架·python框架
Rabitebla3 小时前
【Linux】进程控制(十二) 自定义 Shell(二):内建命令与进程工作目录管理
linux·c++·笔记·学习·bash
eggwyw4 小时前
Anaconda安装卸载的详细流程指南
开发语言·python
码客-ygluu9 小时前
一个通用游戏数据服务器
c++·架构
another heaven9 小时前
【C/C++ Ranges 是零开销抽象吗?拆开管道、惰性求值和编译期膨胀】
c语言·开发语言·c++
SomeOtherTime10 小时前
Rust 闭包语法和原理(AI回答)
开发语言·后端·rust
apcipot_rain10 小时前
C++转Java日记(10)
java·开发语言