.
..; 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:
- Why Arrays are Evil
- A Class Template for N-Dimensional Generic Resizable Arrays
- Bjarne Stroustrup on Multidimensional Array 1, 2
- array vector " C++" 고
AcceleratedCPlusPlus