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; ...
随机推荐
- Excel小写金额转大写金额公式
=IF(ROUND(A6,2)<0,"无效数值",IF(ROUND(A6,2)=0,"零",IF(ROUND(A6,2)<1,"" ...
- mklink
$ mklink /D 参数:创建目录类型链接
- OpenLayers 3 基础知识(一)
OpenLayers 是一个专为Web GIS 客户端开发提供的JavaScript 类库包,用于实现标准格式发布的地图数据访问. 要在你的网页中使用OpenLayers(现用版本:v3.19,1), ...
- ZOJ 3481. Expand Tab
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4278 题意: 给出一些文本片段,把文本中的 Tab 字符根据配置,替换成 ...
- 编译WebRTC遇到的问题总结
唉,本人下载WebRTC的代码都用了几天,真的是惭愧,本来以为很简单的东西,没想到搞了这么久,在下载的过程中,心里骂了无数遍XXX,这鬼东西咋这么难搞.后来终于搞明白了为啥代码总是下载不了,然后又在心 ...
- 使用wcf服务捕捉到“POST http://yourIP/WCFService.svc 405 (Method Not Allowed) ”错误!
在程序中使用了一个wcf服务,调试时无任何问题(win7 64位,iis6.1),发布到部门服务器上没有问题(server2008 64位),但是部署到实际服务器上时(server2008 iis6. ...
- 使用BigDecimal进行精确运算
首先我们先来看如下代码示例: 1 public class Test_1 { 2 public static void main(String[] args) { 3 System.out.print ...
- 一个简单的 MVVM 实现
简介 一个简单的带有双向绑定的 MVVM 实现. 例子 使用 新建一个 ViewModel 对象, 参数分别为 DOM 元素以及绑定的数据即可. 指令 本 MVVM 的指令使用 data 数据, 即 ...
- CA签发工具
#!/bin/bash #author Sun Ying #date:2015-12-17 if [ $# -lt 1 ];then echo -e "\033[34mUsage: `bas ...
- python环境
官网:https://www.python.org windows环境:http://www.cnblogs.com/windinsky/archive/2012/09/20/2695520.html ...