I tried to input numbers in arr[n][m], but there is the problem, that numbers in an array should be constants, that's why I tried to do this:
int n,m;
cin>>n>>m;
int *arr= new int[n][m];
But it doesn't work for m
, what should I do?
I tried to input numbers in arr[n][m], but there is the problem, that numbers in an array should be constants, that's why I tried to do this:
int n,m;
cin>>n>>m;
int *arr= new int[n][m];
But it doesn't work for m
, what should I do?
Although you are suggested to use std::vector
. But as per question to allocated 2-D array you should do.
int row,column;
cin>>row>>column;
int** arr = new int*[row];
for(int i = 0; i < row; ++i)
arr[i] = new int[column];