U E D R , A S I H C RSS

Random Walk2/Vector로2차원동적배열만들기

DeleteMe MultidimensionalArray가 더 ?

.

STL/vector/CookBook 다.

..; 2 만드는 방법 로..; 다 ㅠ.ㅠ 근데 다 그렇게 던데..--;

vector 다 보다가 대 만들다. 고 -_-껏 고 . 모두 0는겁

~cpp 
#include <iostream>
#include <vector>
using namespace std;

vector< vector<int> > ar;  // 반드  다! 러난다.

void Alloc(int nRow, int nCol);
void SetArrayAsZero(int nRow, int nCol);
void Show(int nRow, int nCol);

int main()
{
	int row, col;
	cout << " " ;
	cin >> row;
	cout << "\n : ";
	cin >> col;
	Alloc(row, col);
	return 0;
}

void Alloc(int nRow, int nCol)
{
	ar.resize(nRow);

	for(int i = 0 ; i < nRow ; i++)
		ar[i].resize(nCol);
}

방법 로 감고, 내부로는 1 는 방법 . row*width+col로 다.

see also:

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:27:50
Processing time 0.0136 sec