打印vector内容


  • <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

  • 免责声明!

    本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



     
    粤ICP备18138465号  © 2018-2025 CODEPRJ.COM