C++STL学习笔记_(1)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学习笔记_(1)deque双端数组知识的更多相关文章
- C++STL学习笔记_(2)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; ...
随机推荐
- html基础 2
HTML 文本格式化实例 (我不知道为什么“正常显示文本”这几个字不用加标签,虽然它有在<body>标签内) <html> <body> <b>文本为黑 ...
- MVC中使用内建的HTML辅助方法产生表单元素提交表单与button按钮事件的陷阱
网站模板页有个登陆的退出按钮,当点击时跳转到登陆页面. <button onclick="logout()" >退出</button> $("#l ...
- guava – Optional
过多的使用null可能会导致大量的bugs,Google code 底层代码中,95%的集合类默认不接受null值.对null值,使用快速失败拒绝null比默认接受更好. 另外,null本身的含义很模 ...
- 修复HTTP 503错误
要解决此问题,按照下列步骤操作: 1.验证是否已为虚拟服务器配置了应用程序池.默认的应用程序池是MSSharePointPortalAppPool. 请按照下列步骤来确定虚拟服务器正在使用的应用程序池 ...
- 11,SFDC 管理员篇 - 报表和数据的可视化
1,Report Builder 1,每一个report type 都有一个 primay object 和多个相关的object 2,Primary object with related obje ...
- Sql获取数据集中各类型中的最大值(最新值)
select * from ( SELECT t.*,ROW_NUMBER() over (partition by t.pid order by t.op_time desc) num ...
- What's going on in background?
Did you know that mobile phone manufacturer collect your info without notifying you? Did you know yo ...
- linux系统的常用命令
linux系统中常用的命令如下(以后经常补充): cd .. 返回上一级 cd use 进入use目录
- java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver 错误的解决办法
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver 错误的解决办法 (2011-05-05 16:08:05) 转载▼ ...
- VS中基于对话框的MFC利用换肤改变边框颜色及格式
第一版本: http://ishare.iask.sina.com.cn/f/13836420.html?from=like 2. http://www.cnblogs.com/phinecos/ar ...