/////////////////////
#include<iostream>
using namespace std;
class matrices
{
public:
void myreadin();
void addmatrices(); /////// addition
void submatrices(); /////// subtraction
void multimatrices(); /////// multiplication
void invermatrices(); ////// inverse
// void determatrices(); //////determinant
private:
float a[3][3]; ///// a matrix
float b[3][3]; //// another matrix
float c[3][3]; ///// result thru c
};
int main()
{
matrices m1;
printf("Please enter each elements about matrix \n");
m1.myreadin();
m1.addmatrices();
m1.submatrices();
m1.multimatrices();
m1.invermatrices();
// m1.determatrices();
return 0;
}
void matrices::myreadin()
{
for (int i=0; i<3; i++)
scanf("%f %f ",&a[i],&b[i]);
}
void matrices::addmatrices()
{
int i,o;
for (int i=0; i<3; i++)
{
for (int o=0; o<3; o++)
{
c[i][o]=a[i][o]+b[i][o];
printf("%d ",c[i][o]);
}
printf("\n");
}
}
void matrices::submatrices()
{
int i,o;
for (int i=0; i<3; i++)
{
for (int o=0; o<3; o++)
{
c[i][o]=a[i][o]-b[i][o];
printf("%d ",c[i][o]);
}
printf("\n");
}
}
void matrices::multimatrices()
{
int q,w,e;
for(int q=0; q<3; q++)
for(int w=0; w<3; w++)
{
c[w][e]+ = a[w][q] * b[q][e]; ///////////// If i compile, this part is weird.
}
}
void matrices::invermatrices()
{
int i,j;
for(int i=0; i<3; i++)
{
printf("%d please enter \n",i+1);
for(int j=0; j<3; j++)
{
printf("%d please enter \n",j+1);
scanf("%f", &a[i][j]);
}
printf("\n");
}
}
//void matrices::determatrices()
.
/////////////////////////////////
I need to write a C++ program to do matrix operations. Addition, subtraction,multiplication, inverse of a matrix, and find the determinant of a matrix.... I did roughly addition, subtraction, and muliplcation parts, but not inverse of a matrix, and determinant part..... Can you guys please help me? And I also need to print out but, I am not sure how to do it ...

New Topic/Question
Reply




MultiQuote



|