Question: USING C++: Consider an m by n array A . We want to reshape the array in a one dimensional array B of size m*n

USING C++:

Consider an m by n array A. We want to reshape the array in a one dimensional array B of size m*n, so that the first row of A is copied over to B, then the second row and so on (in general B[k]=A[i][j], where k=n*i+j .)

Write a template function that takes as arguments the following:

  • a dynamic two dimensional array
  • the number of rows of the array
  • the number of columns of the array

The function should return the a one dimensional array containing all the elements of the original array arranged as discussed above. The function prototype is given below:

template  eType* reshape(eType**, int, int);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!