vector 數組初始化指派
說明
總結c++ vector 一維數組,二次元數組的初始化指派。
例子
#include<iostream>
#include<vector>
using namespace std;
int main()
{
// 一次元,直接指派
vector<int> arr = { 1, 2, 3 };
// 二次元直接指派
vector<vector<char>> vec = {{'A', 'B', 'C', 'E'}, {'S', 'F', 'C', 'S'}, {'A', 'D', 'E', 'E'}};
// 一維,指派。其中1為值,3為列數
vector<int> vecInt(3, 1);
// 二維,指派。其中3為列數,vecInt為一次元數組
vector<vector<int>> vec2(3, vecInt);
cout << "endl" << endl;
}