打印vector内容

  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, " "));  
  22.   
  23.     return 0;  
  24. }</span>  
  25. 转自 http://blog.csdn.net/cywosp/article/details/7317977
原文地址:https://www.cnblogs.com/fdd566/p/6635232.html