现在的位置: 首页 > 综合 > 正文

各种专用iterator的用法

2013年08月30日 ⁄ 综合 ⁄ 共 473字 ⁄ 字号 评论关闭

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <vector>
#include <set>
using namespace std;
int main()
{
    istream_iterator<int> in(cin), end;
    set<int> abc(in,end);
    vector<int> ver;       
   
    copy( abc.begin(), abc.end(),
          back_inserter(ver) );
    copy(abc.begin(), abc.end(),
      ostream_iterator<int>(cout, " "));
    cout << endl;
    copy(ver.rbegin(), ver.rend(),
      ostream_iterator<int>(cout, " "));
    cout << endl;
    system("pause");
    return 0;   
}
 

 

抱歉!评论已关闭.