laba2_cpu cpp Defines the entry point for the console application incl

 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
// laba2_cpu.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
#include <ctime>
#include <time.h>
#define N 100
int main(int argc, char* argv[])
{
srand(time(NULL));
int a[N][N];
int b[N][N];
int c[N][N];
int i, j;
int n, m;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
{
a[i][j] = rand() % 10;
b[i][j] = rand() % 10;
c[i][j] = 0;
}
clock_t start;
start = clock();
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
for (m = 0; m < N; m++)
c[i][j] += a[i][m] * b[m][j];
double duration;
duration = (clock() - start) / (double)CLOCKS_PER_SEC;
printf("%f", duration);
system("pause");
return 0;
}