我将 2dim 数组复制到 vector 中,如下所示
vector< vector<int>> path2;
vector<int> temp; // For simplicity
for (int x = 0; x <= 1; x++)
{temp.clear();
for (int y = 0; y < 4; y++)
{
temp.push_back(path1[x][y]);
}
path2.push_back(temp);
}
现在我想在其第二维中插入一个值,我该怎么做?(我知道如何在 1 个暗 vector 中使用 inser())
例如
path2[0][6,0,2,6]
path2[1][6,1,3,6]
现在如何在 1 和 3 之间插入 4 ?
提前谢谢
最佳答案
path2[1].insert(path2[1].begin()+2, 4 );
关于c++ - 在 2dim vector 中插入一个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22897535/