Big Bug Ban

兴趣 践行 创新

stl vector 简单例子

 

#include 
#include 
#include 
using namespace std;

int main()
{
  //一个vector
  vector vec;

  vec.push_back(4);
  vec.push_back(1);
  vec.push_back(3);
  vec.push_back(9);

  // STL中的排序算法
  sort(vec.begin(), vec.end());

  //输出结果
  for (int i = 0; i < vec.size(); i ++)
    cout << vec[i] << "\n";
}

Written by princehaku

12月 18th, 2009 at 9:27 上午

Posted in c/c++

without comments

Leave a Reply