Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Matrix.h"
- #include <iostream>
- #include <vector>
- using namespace std;
- int main(){
- int r1, c1, r2, c2;
- double num;
- while(cin >> r1 >> c1){
- vector <double> coef1, coef2;
- for(int i=0; i<r1*c1; i++){
- cin >> num;
- coef1.push_back(num);
- }
- Matrix m1(r1, c1, coef1);
- cin >> r2 >> c2;
- for(int i=0; i<r2*c2; i++){
- cin >> num;
- coef2.push_back(num);
- }
- Matrix m2(r2, c2, coef2);
- if(m1.isAddable(m2)){
- Matrix res = m1+m2;
- cout << "m1 + m2=" << endl;
- res();
- }else{
- cout << "m1 and m2 are not addable." << endl;
- }
- if(m1.isSubstractable(m2)){
- Matrix res = m1-m2;
- cout << "m1 - m2=" << endl;
- res();
- }else{
- cout << "m1 and m2 are not substractable." << endl;
- }
- if(m1.isMultipliable(m2)){
- Matrix res = m1*m2;
- cout << "m1 * m2=" << endl;
- res();
- }else{
- cout << "m1 and m2 are not multipliable." << endl;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment