# 一维数组的初始化

## 5. vector < int > v(*p, *q);

	int a[3] = { 1,2,3 };
vector<int> v = {1,2,3,4};

vector<int> v2(a, a+2);
for (int i = 0; i < v2.size(); i++)
cout << v2[i] << " ";          //输出为1 2
cout << endl;

vector<int> v3(v.begin()+1, v.end() - 1);
for (int i = 0; i < v3.size(); i++)
cout << v3[i] << " ";   		//输出为2 3


# 二维数组的初始化

## 1.vector < vector < int > > v;

		for (int i = 0; i < v.size(); i++)
v[i].resize(n);


vector<vector<int>> v(3, vector<int>(4,1));


3*4大小的二维数组，值全为1.

## 4.使用指针初始化

		vector<int> v0 = { 1,2,3,4 };
vector<vector<int>> v1(4, v0);
vector<vector<int>> v(v1.begin()+1, v1.end()-1); //此时的v是 {{1,2,3,4},{1,2,3,4}}


	int a[4][5] = { {1,2,3,4,0},{5,6,7,8,0},{9,10,11,12,0},{13,14,15,16,0} };

vector<vector<int>> v(a[0], a[1]);

for (int i = 0; i < v.size(); i++) {
for (int j = 0; j < v[i].size(); j++)
cout << v[i][j] << " ";
cout << endl;
}
/*
此时的输出为
0
0 0
0 0 0
0 0 0 0
*/


08-30 2万+

06-14 2万+
01-27 1万+
09-24 4781
05-22 26万+
06-08 1556
07-10 6万+
09-30 16万+
05-03
05-01 7万+
05-06 613
05-29 9822
03-05 412
10-07 262