vector构造函数通常含有两个参数 

原型如下:

 vector( size_type num, const TYPE &val );

  • 数量(num)和值(val) - 构造一个初始放入num个值为val的元素的Vector

 方法1:

#include <iostream>  
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    int m, n;
    cin >> m >> n ;
    vector<vector<int>>  v1(m, vector<int>(n,123));
    for (int i = 0; i < m; i++){
        for (int j = 0; j < n; j++)
            cout << v1[i][j];
        cout << endl;
    }
    return 0;
}

当然也可以这样:

int N=5, M=6; 
vector<vector<int> > Matrix(N); 
for(int i =0; i< Matrix.size(); i++){ 
   Matrix[i].resize(M); 
}