-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
142 lines (137 loc) · 3.3 KB
/
main.cpp
File metadata and controls
142 lines (137 loc) · 3.3 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <iostream>
#include "matrix.h"
#include <iomanip>
using namespace std;
/// enter & out data of the matrices by using overloaded operator
istream& operator>> (istream& in, matrix& mat){
cout<<"Enter the row of Matrix: ";
in>>mat.row;
cout<<endl;
cout<<"Enter the column of Matrix: ";
in>>mat.col;
cout<<endl;
cout<<"Enter the data of Matrix: ";
mat.data=new int [mat.col*mat.row];
for (int i=0; i<(mat.col*mat.row);++i){
in>>mat.data[i];
}
return in;
}
ostream& operator<< (ostream&out,matrix mat){
cout<<endl<<"The Data of Matrix......."<<endl<<endl;
int counter =0;
for (int x = 0; x<mat.col*mat.row; x++)
{
if (counter == mat.col)
{
cout << endl;
counter = 0;
}
counter += 1;
cout << mat.data[x] <<" ";
}
return out;
}
int main(){
while (true){
matrix mat1,mat2;
int scalar,z;
cout<<endl<<endl;
cout<<"1-operator+\n2-operator-\n3-operator*\n4-operator+(Scalar)\n5-operator-(Scalar)\n6-operator*(Scalar)"<<endl;
cout<<"7-operator+=\n8-operator-=\n9-operator+=(Scalar)\n10-operator-=(Scalar)\n11-operator++\n12-operator--"<<endl;
cout<<"13-bool operator==\n14-bool operator!=\n15-bool isSquare\n16-bool isSymmetric\n17-bool isIdentify\n18-Matrix transpose "<<endl;
cout<<"19-operator= "<<endl;
cin>>z;
if (z==1){
cin>>mat1>>mat2;
cout<<(mat1+mat2);
}
else if (z==2){
cin>>mat1>>mat2;
cout<<(mat1-mat2);
}
else if (z==3){
cin>>mat1>>mat2;
cout<<(mat1*mat2);
}
else if(z==4){
cin>>mat1>>scalar;
cout<<(mat1+scalar);
}
else if(z==5){
cin>>mat1>>scalar;
cout<<(mat1-scalar);
}
else if(z==6){
cin>>mat1>>scalar;
cout<<(mat1 * scalar);
}
else if (z==7){
cin>>mat1>>mat2;
cout<<(mat1+mat2);
}
else if (z==8){
cin>>mat1>>mat2;
cout<<(mat1-mat2);
}
else if (z==9){
cin>>mat1;
cout<<"Enter the Scalar: ";
cin>>scalar;
cout<<endl;
cout<<(mat1+scalar);
}
else if (z==10){
cin>>mat1;
cout<<"Enter the Scalar: ";
cin>>scalar;
cout<<endl;
cout<<(mat1-scalar);
}
else if (z==11){
cin>>mat1;
cout<<(mat1+1);
}
else if (z==12){
cin>>mat1;
cout<<(mat1-1);
}
else if (z==13){
cin>>mat1>>mat2;
bool test=mat2.operator ==(mat1);
cout<<test;
}
else if (z==14){
cin>>mat1>>mat2;
bool test=mat2.operator!=(mat1);
cout<<test;
}
else if (z==15){
cin>>mat1;
bool test=mat1.isSquare();
cout<<test;
}
else if (z==16){
cin>>mat1;
bool test=mat1.isSymetric();
cout<<test;
}
else if (z==17){
cin>>mat1;
bool test=mat1.isIdentity();
cout<<test;
}
else if (z==18){
cin>>mat1;
cout<<mat1.transpose();
}
else if (z==19){
matrix mat;
cin>>mat;
matrix copyMatrix;
copyMatrix=mat;
cout<<copyMatrix;
}
}
return 0;
}