-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path76TwoDArray.cpp
More file actions
49 lines (42 loc) · 871 Bytes
/
76TwoDArray.cpp
File metadata and controls
49 lines (42 loc) · 871 Bytes
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
#include<iostream>
using namespace std;
int main(){
int r1 , c1;
cin>>r1;
cin>>c1;
int A[r1][c1];
for(int i = 0;i<r1;i++){
for(int j = 0;j<c1;j++){
cin>>A[i][j];
}
}
int r2,c2;
cin>>r2;
cin>>c2;
int B[r2][c2];
for(int i = 0;i<r2;i++){
for(int j = 0;j<c2;j++){
cin>>B[i][j];
}
}
if(c1 != r2){
cout<<"Matrix Multiplication not Possible !!!!!!";
}
int C[r1][c2];
for(int i = 0;i<r1;i++){
for(int j = 0;j<r2;j++){
int value = 0;
for(int k = 0;k<r2;k++){
value = value + A[i][k]*B[k][j];
}
C[i][j] = value;
}
}
for(int i = 0;i<r1;i++){
for(int j = 0;j<c2;j++){
cout<<C[i][j]<<" ";
}
cout<<endl;
}
return 0;
}