• 定义方式:vector<int> a; //二维vector<int>a[100]

  • 在末尾压入容器:a.push_back(x);//二维 a[i].push_back(x)

  • 在末尾弹出容器:a.pop_back();

  • 清空容器:a.clear();

  • 查询元素个数:a.size();

  • 其它像数组一样调用就可以了。

  • 看做是一个动态数组

  • 循环遍历:for(vector<int>::iterator it=a.begin();it!=a.end();it++)

  • vector可以存像n*m<=100000这样的数据又能很方便地调用

     

相关文章:

  • 2021-04-04
  • 2022-03-05
  • 2021-09-28
  • 2021-11-13
  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
猜你喜欢
  • 2022-02-13
  • 2021-10-02
  • 2021-12-13
  • 2021-10-29
  • 2021-04-13
  • 2021-07-05
  • 2022-12-23
相关资源
相似解决方案