标签:
#include<vector> #include<iostream> #include<iterator> using namespace std; void pri(vector<int>a) //用输出迭代器将容器中元素输出到标准输出流 { ostream_iterator<int> int_put(cout," "); for(auto it : a) //范围for语句 { *int_put++ = it; } cout << endl; } int main(void) //用输入迭代器把输入值添加到容器 { vector<int> x; istream_iterator<int> int_it(cin); istream_iterator<int> int_eof; while(int_it != int_eof) { x.push_back(*int_it++); } pri(x); return 0; }
标签:
原文地址:http://www.cnblogs.com/7-29/p/5719495.html