首页 > 其他 > 详细

STL

时间:2015-10-10 22:48:03      阅读:271      评论:0      收藏:0      [点我收藏+]


Vector
  1. #include "stdafx.h"
  2. #include "vector"
  3. #include "iostream"
  4. #include "numeric" //accumulate need it
  5. using namespace std;
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8. vector<int> vint;
  9. //初始化vector
  10. for (int i=0; i<10; i++)
  11. {
  12. vint.push_back(i);
  13. }
  14. //使用迭代器
  15. vector<int>::iterator iter;
  16. for (iter = vint.begin(); iter != vint.end(); iter++)
  17. {
  18. cout << *iter << " "; //need * before iter
  19. }
  20. cout << endl;
  21. int sum = accumulate(vint.begin(), vint.end(), 0);
  22. cout << "sum=" << sum << endl;
  23. return 0;
  24. }









STL

原文:http://www.cnblogs.com/gxcdream/p/4868422.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!