1. 程式人生 > >vector二維陣列初始化

vector二維陣列初始化

int main() {
    vector<vector<int> >num = 
        { {1,1,1,0,1,1},{1,0,1,1,1,1},{1,1,1,0,0,1},{1,0,1,0,0,1},{1,1,1,1,1,1} };

    //二維陣列初始化
    //vector<vector<int>> vec(10, vector<int>(10));
    vector<vector<int> >right(num.size(), vector<int>(num[0].size()));
    vector<vector<int> >down(num.size(), vector<int>(num[0].size()));
    construct(num, right, down);
    cout << calculate(num, right, down) << endl;
    return 0;
}

初始化了一個 6*5的二維矩陣矩陣,初始值為0.