C/C++에서 다차원 배열은 간단한 단어로 배열의 배열로 정의됩니다. 다차원 배열에서 데이터는 표 형식(행 주요 순서)으로 저장됩니다. 다음 다이어그램은 차원이 3 x 3 x 3인 다차원 배열에 대한 메모리 할당 전략을 보여줍니다.

알고리즘
Begin Declare dimension of the array. Dynamic allocate 2D array a[][] using new. Fill the array with the elements. Print the array. Clear the memory by deleting it. End
예시 코드
#include <iostream>
using namespace std;
int main() {
int B = 4;
int A = 5;
int** a = new int*[B];
for(int i = 0; i < B; ++i)
a[i] = new int[A];
for(int i = 0; i < B; ++i)
for(int j = 0; j < A; ++j)
a[i][j] = i;
for(int i = 0; i < B; ++i)
for(int j = 0; j < A; ++j)
cout << a[i][j] << "\n";
for(int i = 0; i < A; ++i)
delete [] a[i];
delete [] a;
return 0;
} 출력
0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3