当前位置:网站首页>第十章 STL 之 stack
第十章 STL 之 stack
2022-07-17 10:23:00 【qq_43205256】
1 stack 基本概念

2 stack 常用接口
#include <iostream>
using namespace std;
#include <stack>
//栈容器常用接口
void test01()
{
//创建栈容器 栈容器必须符合先进后出
stack<int> s;
//向栈中添加元素,叫做压栈
s.push(10);
s.push(20);
s.push(30);
while (!s.empty())
{
//输出栈顶元素
cout << "栈顶元素为: " << s.top() << endl;
//弹出栈顶元素
s.pop();
}
cout << "栈的大小为:" << s.size() << endl;
}
int main()
{
test01();
return 0;
}输出结果:
栈顶元素为: 30
栈顶元素为: 20
栈顶元素为: 10
栈的大小为:0边栏推荐
- OpenCV模板
- Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS) (found suitable exact version “11.4“)
- MySQL view
- 【洛谷】P2357 守墓人
- pytorch 调用 cublasLtMatmul 做 gemm同时加bias的代码,写的不错
- 使用 Golang 正确处理五大互联网注册机构的 IP 数据
- C language compilation process
- Etcd database source code analysis -- etcdserver bootstrap recover store from snapshot
- 【C语言】浮点型在内存的存储
- [hero planet July training leetcode problem solving daily] 17th kuansou
猜你喜欢

MySQL 视图

Simple third-party component log desensitization

Utility series - xshell installation, download and use

Etcd database source code analysis - initialize etcdserver structure

【Flink】Flink 设置检查点失败一次就报错 setTolerableCheckpointFailureNumber 不起作用

MySql数据是如何存储在磁盘上存储的?

组件化高级--插槽

uniapp仓库管理系统源码

565. 数组嵌套

OLED displays how to understand the character sizes of 12*6, 16*8, 24*12, etc
随机推荐
Understanding of user / Account / Account
SAP Fiori 的附件处理(Attachment handling)
un7.16:如何在码云上部署项目并邀请组员?
v-mode
KNN分類器
DEDECMS织梦文章列表标题重复显示解决方案
[英雄星球七月集训LeetCode解题日报] 第17日 宽搜
Markdown (5): anchor link
SharePoint接入简要笔记
Code Capriccio: question skimming record (under update)
Line Flow Based Simultaneous Localization and Mapping
Leetcode 197 Rising temperature (July 16, 2022)
Makefile中在命令前加上- 则忽略该命令产生的错误,继续执行下一条命令
idea卡顿且报错:UI was frozen for xxxxx ms问题解决
Vector容器的系列操作( 详解 )
Fundamentals of C language -- 2-2 const keywords and pointers
MySQL 视图
Case sharing | build a one-stop data development platform for hehe information based on linkis+dss
使用 Golang 正确处理五大互联网注册机构的 IP 数据
【性能优化方法论系列】六、总结