-
Notifications
You must be signed in to change notification settings - Fork 0
/
fds3.txt
187 lines (187 loc) · 2.57 KB
/
fds3.txt
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include<iostream>
#include <bits/stdc++.h>
const int MAX = 100;
using namespace std;
class Matrix
{
int
a1[10][10],a2[10][10],c[10][10],sum,a[10][10],s[10][10],m[10][10],i,j,k,n,d;
public:
void getdata();
void display();
void operate();
void trans();
void diagonal();
void sumall();
bool spoint();
};
void Matrix::getdata()
{
cout<<"enter the size of square martix(n*n) : ";
cin>>n;
cout<<"enter the elements of matrix 1 : \n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>a1[i][j];
}
}
cout<<"enter the elements of matrix 2 : \n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>a2[i][j];
}
}
}
void Matrix::operate()
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=a1[i][j]+a2[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
s[i][j]=a1[i][j]-a2[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
m[i][j]=0;
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<n;k++)
{
m[i][j]=m[i][j]+a1[i][k]*a2[k][j];
}
}
}
}
void Matrix::trans()
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=a1[j][i];
}
}
}
void Matrix::diagonal()
{
d=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
{
d=d+a1[i][j];
}
}
}
}
void Matrix::sumall()
{
sum=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
sum=sum+a1[j][i];
}
}
}
void Matrix::display()
{
cout<<"\nadditon of matrix 1 and 2 is\n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<a[i][j]<<"\t";
cout<<"\n";
}
cout<<"\nsubtration of matrix 1 and 2 is\n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<s[i][j]<<"\t";
cout<<"\n";
}
cout<<"\nmultiplication of matrix 1 and 2 is\n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<m[i][j]<<"\t";
cout<<"\n";
}
cout<<"\ntranspose of matrix 1\n";
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cout<<c[i][j]<<"\t";
cout<<"\n";
}
cout<<"\nsum of diagonal elements of matrix 1\n"<<d;
cout<<"\nsum of all elements of matrix 1\n";
cout<<sum;
}
}
}
}
bool Matrix:: spoint()
{
for (int i = 0; i < n; i++)
{
int min_row = a[i][0], col_ind = 0;
for (int j = 1; j < n; j++)
{
if (min_row > a[i][j])
{
min_row = a[i][j];
col_ind = j;
}
}
int k;
for (k = 0; k < n; k++)
{
if (min_row < a[k][col_ind])
{
break;
}
if (k == n)
{
cout <<"Value of Saddle Point : "<< min_row;
return true;
}
}
}
return false;
}
int main()
{
Matrix b;
b.getdata();
b.operate();
b.trans();
b.diagonal();
b.sumall();
b.spoint();
b.display();
return 0;