-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathMultiplication_of_Matrices.c
More file actions
46 lines (46 loc) · 939 Bytes
/
Multiplication_of_Matrices.c
File metadata and controls
46 lines (46 loc) · 939 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
#include <stdio.h>
int main()
{
int n, m, p = 1;
scanf("%d", &m);
scanf("%d", &n);
long long int arr[m][n];
long long int arr1[n][p];
long long int arr2[m][p];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
scanf("%lld", &arr[i][j]);
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < p; j++)
{
scanf("%lld", &arr1[i][j]);
}
}
long long int sum = 0;
for (int a = 0; a < p; a++)
{
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
sum = sum + arr[i][j] * arr1[j][a];
}
arr2[i][a] = sum;
sum = 0;
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < p; j++)
{
printf("%4lld ", arr2[i][j]);
}
printf("\n");
}
return 0;
}