首页 > 代码库 > copy函数与ostream_iterator、reverse_iterator
copy函数与ostream_iterator、reverse_iterator
#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;}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。