Write a function named flatten, that takes a matrix of integers and their dimensions as the arguments, then returns a 1D array such that this array is the “flattened” version of the matrix. Demonstrate the function in the main program. The prototype of the function should look like: int* transpose(int** matrix, int nrow, int ncol); Sample input: Sample output: 12 3 1 2 3 4 5 45 6
int* transpose(int** matrix, const int nrow, const int ncol){
int* result = new int[ncol*nrow];
for(int i = 0;i<nrow;i++){
for(int j = 0;j<ncol;j++){
result[i*nrow+j] = matrix[i][j];
}
}
return result;
}
Write a function named flatten, that takes a matrix of integers and their dimensions as the...