-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckSingleMulti.c
69 lines (60 loc) · 1.38 KB
/
checkSingleMulti.c
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
#include<stdio.h>
#include<stdlib.h>
#define SIZE 1000
#define TRUE 1
#define FALSE 0
int ** C_single;
int ** C_multi;
int flag;
void printMatrix(int ** matrix) {
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
printf("%d ", matrix[i][j]);
}
}
}
int main() {
int i, j;
C_single = (int**)malloc(sizeof(int*)*SIZE);
C_multi = (int**)malloc(sizeof(int*)*SIZE);
for (i = 0; i < SIZE; i++) {
C_single[i] = (int*)malloc(sizeof(int)*SIZE);
C_multi[i] = (int*)malloc(sizeof(int)*SIZE);
}
for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
C_single[i][j] = 0;
C_multi[i][j] = 0;
}
}
FILE *f = fopen("C_singleThread", "r");
int temp = 0, temp2 = 0;
for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
fscanf(f, "%d", &temp);
C_single[i][j] = temp;
}
}
fclose(f);
FILE *g = fopen("C_multiThread", "r");
for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
fscanf(g, "%d", &temp2);
C_multi[i][j] = temp2;
}
}
fclose(g);
flag = TRUE;
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
if (C_single[i][j] != C_multi[i][j]) {
printf("Matrices do not MATCH!\n");
flag = FALSE;
break;
}
}
}
if (flag) {
printf("Matrices MATCHED!\n");
}
}