-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
118 lines (112 loc) · 3.77 KB
/
main.cpp
File metadata and controls
118 lines (112 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <iostream>
#include "operationsFile.hpp"
#include "matrixClass.hpp"
using namespace std;
int main(){
matrixOperations operations;
cout << "Welcome to Matrix Wizard\n";
int input;
do{
cout << "Choose your operation ->\n";
cout << "1. Add A and B\n";
cout << "2. Subtract B from A\n";
cout << "3. Multiply A and B\n";
cout << "4. Transpose a matrix\n";
cout << "5. Exit\n";
cin >> input;
switch(input){
case 1:{
int row1, column1, row2, column2;
cout << "Enter matrix 1 : \n";
cout << "Rows : ";
cin >> row1;
cout << "Columns : ";
cin >> column1;
matrix obj1(row1,column1);
obj1.takeElements();
cout << "Enter matrix 2 : \n";
cout << "Rows : ";
cin >> row2;
cout << "Columns : ";
cin >> column2;
matrix obj2(row2,column2);
obj2.takeElements();
matrix result(row1, column2);
try{
result = operations.add(obj1, obj2);
result.printMatrix();
}catch(int e){
cout << "Illegal operation ! Need matrixes of equal size!\n";
}
break;
}
case 2:{
int row1, column1, row2, column2;
cout << "Enter matrix 1 : \n";
cout << "Rows : ";
cin >> row1;
cout << "Columns : ";
cin >> column1;
matrix obj1(row1,column1);
obj1.takeElements();
cout << "Enter matrix 2 : \n";
cout << "Rows : ";
cin >> row2;
cout << "Columns : ";
cin >> column2;
matrix obj2(row2,column2);
obj2.takeElements();
matrix result(row1, column2);
try{
result = operations.subtract(obj1, obj2);
result.printMatrix();
}catch(int e){
cout << "Illegal operation ! Need matrixes of equal size!\n";
}
break;
}
case 3:{
int row1, column1, row2, column2;
cout << "Enter matrix 1 : \n";
cout << "Rows : ";
cin >> row1;
cout << "Columns : ";
cin >> column1;
matrix obj1(row1,column1);
obj1.takeElements();
cout << "Enter matrix 2 : \n";
cout << "Rows : ";
cin >> row2;
cout << "Columns : ";
cin >> column2;
matrix obj2(row2,column2);
obj2.takeElements();
matrix result(row1, column2);
try{
result = operations.multiply(obj1, obj2);
result.printMatrix();
}catch(int e){
cout << "Illegal Operation ! Incompatible Matrixes\n";
}
break;
}
case 4:{
int row, column;
cout << "Enter matrix : \n";
cout << "Rows : ";
cin >> row;
cout << "Columns : ";
cin >> column;
matrix obj(row,column);
obj.takeElements();
matrix result(row, column);
result = operations.transpose(obj);
result.printMatrix();
break;
}
case 5:
break;
}
}while(input!=5);
return 0;
}