Question
write a C++ program for this, if it is still not clear, please indicate which part. Thanks This is what I got so far: #include
write a C++ program for this,
if it is still not clear, please indicate which part. Thanks
This is what I got so far:
#include
const int MAX_ROWS = 15; const int MAX_COLS = 15; const int Larg_Num = 3;
class Matrix { // Represents a varying-size matrix that can be input from a file public: Matrix() {} Matrix(int, int, int); // Constructor that initializes matrix size and sets all valid elements to given initial value void transpose(Matrix&); // Changes passed matrix to transpose of current object matrix void showDiagonal() const; // Displays diagonal of a square matrix void uppertriangularmatrix(Matrix&); // ZERO out lower traiangilar matrix. void findlarge(int [Larg_Num][3]) const;
private: int rows; int cols; int mat[MAX_ROWS][MAX_COLS]; friend ostream& operator> (istream&, Matrix&); friend Matrix& operator*= (Matrix&, const Matrix&); };
//*this = prod;
//return *this;
int main() { Matrix m; Matrix t; int largest[Larg_Num][3]; ifstream infile("matrix_chap9_5.txt", ios::in); infile >>m; m.transpose(t); t *= m; cout
Matrix::Matrix(int i, int j, int z) { rows = i; cols = j; for (i = 0; i
void Matrix::transpose(Matrix &t) { t.rows = cols t.cols = rows for (int i = 0; i
void Matrix::showDiagonal() const { if (rows == cols) { for (int i = 0; i
void Matrix::findlarge(int large[Larg_Num][3]) const { for (i = 0; i large[0][0]) for (int k = ; mat[i][j] >= large[k][0]; ++k) { large[k][0] = large[k + 1][0]; large[k][1] = large[k + 1][1]; large[k][2] = large[k + 1][2]; } large[--k][0] = mat[i][j]; large[k][1] = i; large[k][2] = j; } } }
ostream & operator
istream & operator >> (istream &is, Matrix &m) { for (int i = 0; i > m.mat[i][j]; } } return is; }
Matrix & operator*=(Matrix &, const Matrix &) { int val, i, j, k;
Matrix prod;
if (cols != m2.rows) {
cout
prod.rows = 0; prod.cols = 0;
} else {
prod.rows = rows; prod.cols = m2.cols;
for (i = 0; i
for (j = 0; j
val = 0;
for (k = 0; k
val += mat[i][k] * m2.mat[k][j];
prod.mat[i][j] = val; }
The transpose of a matrix he Put values or b betWeen 0 and 1E radians. and columns. is formed by interchanging the matrix's rows Thus the transpose of matrix 2 6 10 4 8 12 10 12 Expand the definition of class Matrix to include a transpose member function, and use this function in your solution to the following problem. The organizers of an in-house software engineering conference for a small consulting company are trying to minimize scheduling conflict by scheduling the most popular presentations at different times. First the planners survey the ten participants to determine which of the five pre- sentations they want to attend. Then they construct a matrix A in which a 1 in entry ij means that participant i wants to attend presentation j The transpose of a matrix he Put values or b betWeen 0 and 1E radians. and columns. is formed by interchanging the matrix's rows Thus the transpose of matrix 2 6 10 4 8 12 10 12 Expand the definition of class Matrix to include a transpose member function, and use this function in your solution to the following problem. The organizers of an in-house software engineering conference for a small consulting company are trying to minimize scheduling conflict by scheduling the most popular presentations at different times. First the planners survey the ten participants to determine which of the five pre- sentations they want to attend. Then they construct a matrix A in which a 1 in entry ij means that participant i wants to attend presentation jStep 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