↵
~~~~~↵
#include <iostream>↵
using namespace std;↵
↵
void make_allocation(int n, int m, int ***ptr){ //where n is row and m is column↵
*ptr = new int* [n];↵
for(int i = 0; i < n; i++){↵
*ptr[i] = new int[m];↵
}↵
}↵
↵
int main() {↵
int n,m;↵
cin>>n>>m;↵
int **ptr = NULL;↵
make_allocation(n,m, &ptr);↵
for(int i=0;i<n;i++)for(int j=0;j<m;j++)ptr[i][j] = i+j;↵
for(int i=0;i<n;i++)for(int j=0;j<m;j++)cout<<ptr[i][j]<<" ";↵
return 0;↵
}↵
~~~~~
~~~~~↵
#include <iostream>↵
using namespace std;↵
↵
void make_allocation(int n, int m, int ***ptr){ //where n is row and m is column↵
*ptr = new int* [n];↵
for(int i = 0; i < n; i++){↵
*ptr[i] = new int[m];↵
}↵
}↵
↵
int main() {↵
int n,m;↵
cin>>n>>m;↵
int **ptr = NULL;↵
make_allocation(n,m, &ptr);↵
for(int i=0;i<n;i++)for(int j=0;j<m;j++)ptr[i][j] = i+j;↵
for(int i=0;i<n;i++)for(int j=0;j<m;j++)cout<<ptr[i][j]<<" ";↵
return 0;↵
}↵
~~~~~