打印vector内容
2017-03-28 15:52 fdd566 阅读(1995) 评论(0) 编辑 收藏 举报- <span style="font-size:14px;">#include <iostream>
- #include <vector>
- #include <iterator>
- #include <algorithm>
- using namespace std;
- int main (int argc, char *argv[])
- {
- int n = 10;
- vector<int> v;
- //append integers 0 to n-1 to v
- for (int i = 0; i < n; ++i) {
- v.push_back(i);
- }
- //random shuffle the values of v
- random_shuffle (v.begin(), v.end());
- //print all values of v to screen
- copy (v.begin(), v.end(), ostream_iterator<int> (cout, "\n"));
- return 0;
- }</span>
- 转自 http://blog.csdn.net/cywosp/article/details/7317977