STL 小白学习(5) stack栈
#include <iostream>
#include <stack>
//stack 不遍历 不支持随机访问 必须pop出去 才能进行访问
using namespace std; void test01() {
//初始化
stack<int> s1;
stack<int> s2(s1);
//stack操作
//首先是压栈
s1.push();
s1.push();
s1.push();
//返回栈顶元素
cout << "栈顶元素为 " << s1.top() << endl;
//出栈
s1.pop(); //打印 不能遍历 cout top后只能pop掉 打印下一个元素
while (!s1.empty()) {
cout << s1.top() << endl;
s1.pop();
} //size()
cout <<"size: "<< s1.size() << endl; //栈容器存放对象指针 自练
//栈容器存放对象
}
int main() { }
STL 小白学习(5) stack栈的更多相关文章
- stl容器学习——queue,stack,list与string
目录 头文件 string 目录部分 1.string的定义及初始化 ① 用一个字符串给另一个字符串赋值 ②用字符串常量对字符串进行赋值 ③ 用n个相同的字符对字符串赋值 2.string的运算符及比 ...
- STL 小白学习(1) 初步认识
#include <iostream> using namespace std; #include <vector> //动态数组 #include <algorithm ...
- STL 小白学习(10) map
map的构造函数 map<int, string> mapS; 数据的插入:用insert函数插入pair数据,下面举例说明 mapStudent.insert(pair<, &qu ...
- STL 小白学习(9) 对组
void test01() { //构造方法 pair<, ); cout << p1.first << p1.second << endl; pair< ...
- STL 小白学习(8) set 二叉树
#include <iostream> using namespace std; #include <set> void printSet(set<int> s) ...
- STL 小白学习(7) list
#include <iostream> using namespace std; #include <list> void printList(list<int>& ...
- STL 小白学习(6) queue
//queue 一端插入 另一端删除 //不能遍历(不提供迭代器) 不支持随机访问 #include <queue> #include <iostream> using nam ...
- STL 小白学习(4) deque
#include <iostream> #include <deque> //deque容器 双口 using namespace std; void printDeque(d ...
- STL 小白学习(3) vector
#include <iostream> using namespace std; #include <vector> void printVector(vector<in ...
随机推荐
- 初始化vue项目,报错This is probably not a problem with npm,there is likely additional logging output above
https://blog.csdn.net/ink_if/article/details/79015811 参考别人的博客 初始化项目,vue init webpack-simple demo 然后n ...
- javascript callback
https://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/ MDN web docs htt ...
- python_字符串的格式化输出
name = input("Name:")age = int(input("Age:")) input: 输入的内容默认为字符串格式job = input(&q ...
- Mybatis经常被问到的面试题
1. #{}和${}的区别是什么? #{}是预编译处理,${}是字符串替换. Mybatis在处理#{}时,会将sql中的#{}替换为?号,调用PreparedStatement的set方法来赋值: ...
- fiddler学习总结--手机端(APP/微信小程序)抓包
步骤一.手机和电脑要在同一个局域网中 步骤二.完成fiddler的基本配置,与web端抓包一样: TOOLS-->options-->connections-->1.设置端口:2.勾 ...
- SpringMVC 允许跨域访问 也可以选择限制指定IP 允许访问 对象的数据传输
java ajax
- js 图片无缝滚动
html部分 <div id="roll"> <a href="javascript:void(0)" class="prev&qu ...
- oracle 老用户数据导入新建用户
$sqlplus/nolog #使用PLSQL进入oracleSQL>conn/as sysdba #进入sysdba权限CREATE DIRECTORY datadir1 AS ' ...
- Java this关键字 学习笔记
前言: 这篇博文就是系统的学习一下Java中的this关键字,本人对this关键字的理解知识简单的停留在对 类的成员变量进行赋值,这次所以决定系统的体会一下this 关键字 转自:https://b ...
- msvc命令行cl编译c程序问题及解决
1.cmd命令行cl提示没有这玩意儿 装上Visual Studio之类 2.cl main.c提示缺dll everything搜dll所在路径,在环境配置PATH增加对应bin.IDE 3.cl ...