c++提供了std::vector,是一种方便易于使用的动态数组
#include<iostream>
#include <vector> //使用动态数组类std::vector,需要包含头文件vector
using namespace std;
int main()
{
// int a[2][3]={};
// cout << a[1][1];
vector<int> a(3);//创建初始长度为3的数组
int b=0;
a[0] = 123;
a.push_back(345);//将数字插入到数组末尾
a.push_back(123);//将数字插入到数组末尾
b=a.size();//获取数组长度
cout << b;
return 0;
}