U E D R , A S I H C RSS

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

DeleteMe MultidimensionalArray ?

.


..; 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.0354 sec