C++ deque const_iterator const_reverse_iterator运用实例
C++ deque const_iterator const_reverse_iterator运用实例
#include <iterator> #include <iostream> #include <deque> #include <algorithm> using namespace std; void print1(int elem1) { cout << "" << elem1 << endl; } int main() { deque<int> deque1 = {1,2,3,4,5,6,7,8,9}; deque<int>::const_iterator c_iter1; c_iter1 = find(deque1.cbegin(),deque1.cend(),2); deque<int>::const_iterator c_iter2; c_iter2 = find(deque1.cbegin(), deque1.cend(), 7); for_each(c_iter1, c_iter2, print1); cout << endl; deque<int>::const_reverse_iterator r_iter1(c_iter1); deque<int>::const_reverse_iterator r_iter2(c_iter2); for_each(r_iter2,r_iter1,print1); cout << endl; system("pause"); return 0; }
2
3
4
5
6
6
5
4
3
2
请按任意键继续. . .
代码参考:C++标准库(第2版)
相关推荐
文山羊 2020-11-07
susmote 2020-11-07
拉斯厄尔高福 2020-11-04
xceman 2020-10-23
hellojunz 2020-10-23
caojhuangy 2020-10-12
xinyupan 2020-09-28
lousir 2020-09-27
一个逗逗 2020-09-22
Maryhuan 2020-09-20
rkhstar 2020-09-09
DreamSnow 2020-09-09
aehousmantao 2020-09-03
tkernel 2020-09-03
abfdada 2020-08-26
svap 2020-08-25
二十不悔三十而立 2020-08-19
FlightForever 2020-08-17
joyjoy0 2020-08-13