Question
* What I have so far for Problem #3 ]: #include struct Matrix { double *X; // Matrix elements pointer int n_rows, n_columns; // Rows
* What I have so far for Problem #3]:
#include
struct Matrix { double *X; // Matrix elements pointer int n_rows, n_columns; // Rows and column dimensions };
void DefineMatrix(Matrix &A, int rows, int columns) { A.n_rows = rows; A.n_columns = columns; A.X = (double *)calloc(rows * columns, sizeof(double)); }
void DisplayMatrix(Matrix A) { for (int i = 0; i
void SpecifyMatrixElements(Matrix &A) { std::cout > A.X[i + k* A.n_rows]; } } }
void TransposeMatrix(Matrix A, Matrix &B){ for (int i = 0; i
int main() { Matrix A,B; int A_rows, A_columns, B_rows, B_columns; std::cout > A_rows; std::cout > A_columns; DefineMatrix(A, A_rows, A_columns); SpecifyMatrixElements(A); DisplayMatrix(A); std::cout
// SpecifyMatrixElements(A); DisplayMatrix(B); // DefineMatrix(B, A_columns, A_rows); // SpecifyMatrixElements(B); // DisplayMatrix(B); }
* While the code does end up working as you can see in the console window below, the transposed matrix is generated incorrectly which makes me believe I need to fix the void transposematrix function. Please let me know how I can fix this.
sh -c make -s ./main Please enter the number of rows for Matrix A 2 Please enter the number of columns for Matrix A 3 Specify elements for Matrix A Enter Matrix element A[0][0] : 1 Enter Matrix element A[0][1] : 2 Enter Matrix element A[0][2] : 3 Enter Matrix element A[1][0] : 4 Enter Matrix element A[1][1] : 5 Enter Matrix element A[1][2] : 6 1 2 3 4 5 6 Matrix B (A Transpose): 1 3 5 2 4 6
* What I have so far for Problem #4]:
#include
using namespace std;
vector void display_matrices(vector int main() { vector * For this problem, the console only reverses the numbers in each individual row rather than the whole sequence as the problem wants. Your assistance with this would also be so greatly appreciated. Thank you! Console Window: sh -c make -s ./main Matrix 1: 3 2 1 6 5 4 9 8 7 Matrix 2: 1 2 3 4 5 6 7 8 9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started