C++ Stream(串流)迭代器
C++ Stream(串流)迭代器
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using namespace std; int main() { ostream_iterator<int> intWriter(cout,"\n"); *intWriter = 42; intWriter++; *intWriter = 77; intWriter++; *intWriter = -5; vector<int> vector1 = {1,2,3,4,5,6,7,8,9}; copy(vector1.cbegin(),vector1.cend(),ostream_iterator<int>(cout)); cout << endl; copy(vector1.cbegin(),vector1.cend(),ostream_iterator<int>(cout," < ")); cout << endl; system("pause"); return 0; }
42
77
-5
123456789
1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9 <
请按任意键继续. . .
代码参考:C++标准库(第2版)
相关推荐
kong000dao0 2020-04-29
JnX 2020-09-21
joyjoy0 2020-09-18
Jan 2020-08-17
shenxiuwen 2020-08-01
Andrewjdw 2020-07-26
fanhuasijin 2020-06-21
丽丽 2020-06-08
容数据服务集结号 2020-06-08
czsay 2020-06-01
程序员之怒 2020-04-26
wmsjlihuan 2020-04-26
oDongTianShuiYue 2020-04-26
breakpoints 2020-04-20
卷卷萌 2020-04-20
RocNg 2020-04-18
小菜鸟的代码世界 2020-03-27
HongKongPython 2020-03-26