Write Function Named Flatten Takes Matrix Integers Dimensions Arguments Returns 1d Array A Q37217525

Write a function named flatten, that takes a matrix of integersand their dimensions as the arguments, then returns a 1D array suchthat this array is the “flattened” version of the matrix.Demonstrate the function in the main program. The prototype of thefunction should look like: int* transpose(int** matrix, int nrow,int ncol); Sample input: Sample output: 12 3 1 2 3 4 5 45 6


Answer


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++){

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.