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; ...
随机推荐
- 我们是如何拿下Google和Facebook Offer的?
http://posts.careerengine.us/p/57c3a1c1a09633ee7e57803c 大家好,我是小高,CMU CS Master,来Offer第一期学员,2014年初在孙老 ...
- (1)线程的同步机制 (2)网络编程的常识 (3)基于tcp协议的编程模型
1.线程的同步机制(重点)1.1 基本概念 当多个线程同时访问同一种共享资源时可能会造成数据的覆盖和不一致等问题,此时就需要对线程之间进行协调和通信,该方式就叫线程的同步机制. 如: 2003年左右 ...
- October 08th 2017 Week 41st Sunday
Talent wins games, but teamwork and intelligence wins championships. 才华让你赢得比赛,团队及智慧让你赢得冠军. But the m ...
- ZT 互联网——降级论
互联网——降级论 投递人 Astar 发布于 2012-07-06 09:54 评论(110) 有30531人阅读 原文链接 [收藏] « » 文/meditic 几乎一年没有写博客了,说没时间 ...
- Java 替换空格
题目描述 请实现一个函数,将一个字符串中的空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 解一: 由于最近在学习Head F ...
- SOJ 4583 动态规划之分组背包
Description Sidney想去Gandtom家玩.但Sidney家和Gandtom家之间是高低不平.坑坑洼洼的土路.所以他需要用他的背包装几袋稀的泥,在路上铺平一些干的土,使路变成平整的泥土 ...
- sql排序方法
SQL Server中使用order by charindex按指定顺序排序 在使用SQL Server数据库编程中,有时需要对取出来的数据按照指定的顺序排序,例如,取出来的数据某个字段值有张三.李四 ...
- Alias自定义命令
[root@localhost etc]# type home --检查是否占用-bash: type: home: not found[root@localhost etc]# alias h ...
- layui弹出层之应用实例讲解
从酒店管理系统到智能门锁及其现在的资源共享平台,layui框架,我们团队用的比较多的就是这个layui弹出层. layui弹出层,除了页面iframe层我们比较常用还有就是表单校验和其他相关的友好提示 ...
- Python:基础知识(二)
常用模块 urllib2 :用于发送网络请求,获取数据 (Pyhton2中的urllib2工具包,在Python3中分拆成了urllib.request和urllib.error两个包.) json: ...