Quickpaste.it
Create Paste
Top Pastes
Recent Pastes
Settings
Account
Matrix
Created By
Anonymous
Expires never
Raw
Download
0
cout<<"\n\tMatrix Addition is not possible the result is incorrect\n\n"; temp.x=0; temp.y=0; } else { temp.x=x; temp.y=y; } for(int i=0;i<x;i++) for(int j=0;j<y;j++) temp.matrix[i][j]=matrix[i][j]+b.matrix[i][j]; return temp; } Matrix Matrix::operator*(Matrix b) { Matrix r; if((x!=b.y)||(y!=b.x)) { cout<<"\n\tMatrix Multiplication is not possible the result is incorrect\n\n"; r.x=0; r.y=0; } else { r.x=x; r.y=b.y; } for(int i=0;i<10;i++) for(int j=0;j<10;j++) r.matrix[i][j]=0; for(int f=0;f<x;f++) for(int g=0;g<b.y;g++) for(int k=0;(k<y)||(k<b.x);k++) cout<<"\n\tMatrix Addition is not possible the result is incorrect\n\n"; temp.x=0; temp.y=0; } else { temp.x=x; temp.y=y; } for(int i=0;i<x;i++) for(int j=0;j<y;j++) temp.matrix[i][j]=matrix[i][j]+b.matrix[i][j]; return temp; } Matrix Matrix::operator*(Matrix b) { Matrix r; if((x!=b.y)||(y!=b.x)) { cout<<"\n\tMatrix Multiplication is not possible the result is incorrect\n\n"; r.x=0; r.y=0; } else { r.x=x; r.y=b.y; } for(int i=0;i<10;i++) for(int j=0;j<10;j++) r.matrix[i][j]=0; for(int f=0;f<x;f++) for(int g=0;g<b.y;g++) for(int k=0;(k<y)||(k<b.x);k++) .matrix[f][g]+=matrix[f][k]*b.matrix[k][g]; return r; } int Matrix::count; void main() { Matrix a,b,c; int cnt; cnt = Matrix::objCount(); cout<<"\nEnter the Rows and Columns of first Matrix :\n"; a.get(); cout<<"\nEnter the Rows and Columns of second Matrix :\n"; b.get(); c=a+b; cout<<"The Matrix Addition is:\n"; c.put(); c=a*b; cout<<"\n\t Matrix Multiplication is:\n"; c.put(); cout << "\nNumber of Matrix objects Created :" << cnt; }