-
Notifications
You must be signed in to change notification settings - Fork 0
/
ass1_2_a.cpp
41 lines (34 loc) · 924 Bytes
/
ass1_2_a.cpp
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
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
clock_t start, end;
start = clock();
int n;
cin >> n;
int M1[n][n];
int M2[n][n];
int M[n][n];
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
M1[i][j] = rand() % 10;
M2[i][j] = rand() % 10;
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
int p = 0;
for (int k = 0; k < n; k++){
p += M1[i][k] * M2[k][j];
}
M[i][j] = p;
}
}
end = clock();
double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
cout << "Time taken by program is : " << fixed
<< time_taken << setprecision(5);
cout << " sec " << endl;
return 0;
}