#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
typedef vector<int> Vector;
void printVector(Vector v)
{
const int nSize = (int)(v.size());
for(int i = 0;i < nSize;i++)
{
cout << v[i] << " ";
}
cout << endl;
}
int main()
{
int b[7]={
1,2,3,4,5,6,7};
Vector a(b,b+7);
cout << "------遍历a------" << endl;
printVector(a);
cout << "a返回第一元素:" << a.front() << endl;//返回第一元素
cout << "a返回末尾元素:"
C++ vector用法
最新推荐文章于 2022-08-23 11:31:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)