Hatena::Grouptopcoder

naoya_t@topcoder RSSフィード

2009-05-20

vectorで多次元配列を作る場合の初期化

| 02:19 | vectorで多次元配列を作る場合の初期化 - naoya_t@topcoder を含むブックマーク はてなブックマーク - vectorで多次元配列を作る場合の初期化 - naoya_t@topcoder vectorで多次元配列を作る場合の初期化 - naoya_t@topcoder のブックマークコメント

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

知らなかった...

トラックバック - https://topcoder-g-hatena-ne-jp.jag-icpc.org/n4_t/20090520