您的位置:首页 > 其它

打印vector内容

2017-03-28 15:52 113 查看
  1. <span style="font-size:14px;">#include <iostream>  
  2. #include <vector>  
  3. #include <iterator>  
  4. #include <algorithm>  
  5.   
  6. using namespace std;  
  7.   
  8. int main (int argc, char *argv[])  
  9. {  
  10.     int n = 10;  
  11.     vector<int> v;  
  12.   
  13.     //append integers 0 to n-1 to v  
  14.     for (int i = 0; i < n; ++i) {  
  15.         v.push_back(i);  
  16.     }  
  17.   
  18.     //random shuffle the values of v  
  19.     random_shuffle (v.begin(), v.end());  
  20.     //print all values of v to screen  
  21.     copy (v.begin(), v.end(), ostream_iterator<int> (cout, "\n"));  
  22.   
  23.     return 0;  
  24. }</span>  
  25. 转自 http://blog.csdn.net/cywosp/article/details/7317977
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: