C++:vector>二维数组的初始化


1. vector二维数组初始化方法:


2.示例代码

unsigned int rows = costMatrix.rows();

unsigned int cols = costMatrix.cols();

vector< vector > costFunc(rows,vector(cols,0));

for (unsigned int i = 0; i < rows; ++i)

{

    for (unsigned int j = 0; j < cols; ++j)

    {

        costFunc[i][j] = (double)costMatrix(i,j);

    }

}


参考:

1.https://blog.csdn.net/sss_369/article/details/102469913

你可能感兴趣的:(C++:vector>二维数组的初始化)