码迷,mamicode.com
首页 > 其他好文 > 详细

copy函数与ostream_iterator、reverse_iterator

时间:2014-08-15 20:57:09      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   for   ar   

#include <iostream>
#include <iterator>
#include <vector>

int main()
{
    using namespace std;
    int casts[10]={6,7,2,9,4,11,8,7,10,5};
    vector<int> dice(10);
    copy(casts,casts+10,dice.begin());
    cout << "Let the dice be cast!\n";
    ostream_iterator<int,char> out_iter(cout," ");
    copy(dice.begin(),dice.end(),out_iter);
    cout << endl;
    cout << "Implicit use of reverse iterator.\n";
    copy(dice.rbegin(),dice.rend(),out_iter);
    cout << endl;
    cout << "Explicit use fo reverse iterator.\n";
    vector<int>::reverse_iterator ri;
    for(ri=dice.rbegin();ri!=dice.rend();ri++)
        cout << *ri <<  ;
    cout << endl;
    return 0;
}

bubuko.com,布布扣

copy函数与ostream_iterator、reverse_iterator,布布扣,bubuko.com

copy函数与ostream_iterator、reverse_iterator

标签:style   blog   http   color   os   io   for   ar   

原文地址:http://www.cnblogs.com/lakeone/p/3915576.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!