C++STL学习笔记_(2)deque双端数组知识
#include<iostream>
using namespace std;
#include "deque"
#include "algorithm" void printD(deque <int> &d)
{
for (deque<int>::iterator it = d.begin();it != d.end();it++)
{
cout<<*it<<endl;
}
}
void main41()
{
deque<int> d1;
//尾部放入三个元素
d1.push_back(1);
d1.push_back(3);
d1.push_back(5); d1.push_front(-11);
d1.push_front(-33);
d1.push_front(-55); cout<<"头部元素"<<d1.front()<<endl;
cout<<"尾部元素"<<d1.back()<<endl; printD(d1); d1.pop_front();
d1.pop_back();
printD(d1); //查找 -33在数组下标的值
deque<int>::iterator it = find(d1.begin(),d1.end(),-33);
if (it != d1.end())
{
cout<<"-33的数组下标是"<<distance(d1.begin(),it)<<endl;
}
else
{
cout<<"没有找到-33的元素"<<endl;
} }
void main()
{
main41();
cout<<"hello...\n"<<endl;
system("pause");
return;
}
C++STL学习笔记_(2)deque双端数组知识的更多相关文章
- C++STL学习笔记_(1)deque双端数组知识
#include<iostream> using namespace std; #include "deque" #include "algorithm&qu ...
- C++STL学习笔记_(1)string知识
/*============================================ string是STL的字符串类型,通常用来表示字符串 = ======================== ...
- C++STL学习笔记_(3)stack
10.2.4stack容器 Stack简介 ² stack是堆栈容器,是一种"先进后出"的容器. ² stack是简单地装饰deque容器而成为另外的一种容器. ² #inc ...
- C++STL学习笔记_(4)queue
10.2.5Queue容器 Queue简介 ² queue是队列容器,是一种"先进先出"的容器. ² queue是简单地装饰deque容器而成为另外的一种容器. ² #inc ...
- C++STL学习笔记_(1)vector知识
#include<iostream> using namespace std; #include "vector" //数组元素的 添加和删除 void main31( ...
- Effective STL 学习笔记 Item 30: 保证目标区间足够大
Effective STL 学习笔记 Item 30: 保证目标区间足够大 */--> div.org-src-container { font-size: 85%; font-family: ...
- jQuery源代码学习笔记_工具函数_noop/error/now/trim
jQuery源代码学习笔记_工具函数_noop/error/now/trim jquery提供了一系列的工具函数,用于支持其运行,今天主要分析noop/error/now/trim这4个函数: 1.n ...
- STL学习系列三:Deque容器
1.Deque简介 deque是“double-ended queue”的缩写,和vector一样都是STL的容器,deque是双端数组,而vector是单端的. deque在接口上和vector非常 ...
- Effective STL 学习笔记 39 ~ 41
Effective STL 学习笔记 39 ~ 41 */--> div.org-src-container { font-size: 85%; font-family: monospace; ...
随机推荐
- SQL Server错误处理
一.SQLServer数据库引擎错误 1.查询系统错误信息 SQLServer在每个数据库的系统视图sys.messages中存储系统自定义(Message_id <= 50000)和用户自定义 ...
- React Native 基础报错及解决方案记录
刚开始上手RN,碰到很多坑,记录一下.碰到问题多去看看github上面的issue! 启动命令react-native run-ios报错 1.:xcrun: error: unable to fin ...
- 【bzoj 4154】[Ipsc2015]Generating Synergy
题目 大概已经掌握熟练码出\(kdt\)的技能了 发现距离子树根节点\(x\)不超过\(l\)的点可以用两种方式来限制,首先\(dfs\)序在\([dfn_x,dfn_x+sum_x)\)中,深度自然 ...
- 【转】合格PHP工程师的知识结构
PHP的运行环境 连环境都搞不起来,就是你有多么喜欢PHP,那也是白搭,开始我们大多会使用集成环境软件例如xampp,wamp.随着知识的增加慢慢要学会自己搭建运行环境,例如 Linux(Ubuntu ...
- Hive学习之路 (九)Hive的内置函数
数学函数 Return Type Name (Signature) Description DOUBLE round(DOUBLE a) Returns the rounded BIGINT valu ...
- 【JavaScript】赛码网前端笔试本地环境搭建
参考:https://hoofoo.me/article/2017-04-11/%E8%B5%9B%E7%A0%81%E7%BD%91%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AF ...
- python 小技巧同时迭代多个列表,多变量同时运算
再来一个大家很熟悉的 dict={"a": "b","c": "d"}k,v=dict.items()print(k,v ...
- http协议cookie结构分析
Http协议中Cookie详细介绍 Cookie总是保存在客户端中,按在客户端中的存储位置,可分为内存Cookie和硬盘Cookie.内存Cookie由浏览器维护,保存在内存中,浏览器关闭后就消失 ...
- window.open 防止浏览器拦截
https://blog.csdn.net/sinat_37255207/article/details/89374416 网上试了很多方法 最终只有一种可以 var newWin = window. ...
- BZOJ4033 [HAOI2015]树上染色
本来是考虑, $ f[x][i][0/1] $ 表示 $ x $ 子树中有$i$个黑点,且 $ x $ 是白点/黑点.但是这里的答案是要统计不同的子树的贡献的.所以就gg了. 看了题解. 应该是要设$ ...