2009-05-20
vectorで多次元配列を作る場合の初期化
Multidimensional arrays are very important. The simplest way to create the two-dimensional array via vector is to create a vector of vectors.
vector< vector<int> > Matrix;It should be clear to you now how to create the two-dimensional vector of given size:
int N, M; // ... vector< vector<int> > Matrix(N, vector<int>(M, -1));Here we create a matrix of size N*M and fill it with -1.
Power up C++ with the Standard Template Library: Part I - Algorithm Tutorials
知らなかった...