#include using namespace std; struct matrix { int rows, cols; double * arrayptr; void print() { cout << "rows = " << rows << " cols = " << cols << "\n"; } matrix(int r, int c) { rows = r; cols = c; arrayptr = new double[rows*cols]; } ~matrix(); double get(int a, int b); void set(int row, int col, double value); void resize(int rsize, int csize); matrix clone(); }; matrix::~matrix() { delete [] arrayptr; arrayptr = NULL; } void matrix::resize(int rsize, int csize) { cout << "resizing...\n"; int rowlim, collim; if (rsize<0 || csize<0) { cerr << "Error in resize\n"; return; } if (rsize> answer; if (answer == 'N') return; } else { if (rsize>rows) rowlim = rows; if (rsizecols) collim = cols; if (csizerows && col>cols) resize(row+1,col+1); else if (row>rows) resize(row+1,cols); else if (col>cols) resize(rows,col+1); arrayptr[row*cols+col] = value; } double matrix::get(int a, int b) { if (a<0 || a>=rows || b<0 || b>=cols) { cerr << "Error in get\n"; return NULL; } return arrayptr[a*cols+b]; } matrix matrix::clone() { matrix arrayclone(rows,cols); arrayclone.arrayptr = new double[rows*cols]; for (int i=0; iarrayptr = new double[a.rows*b.cols]; double *sum = new double[a.rows*b.cols]; for (int i=0; iarrayptr[i*b.cols+j] = sum[i*b.cols+j]; } } } return result; } void transpose(matrix &a) { double *result = new double[a.rows*a.cols]; for (int i=0; i