-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw7.c
38 lines (36 loc) · 850 Bytes
/
hw7.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
#include <stdio.h>
#include <stdlib.h>
#define ROWS 200
#define COLS 198
int main() {
FILE* in;
FILE* out;
in = fopen("data.txt", "r");
out = fopen("output.txt", "w");
float A[ROWS][COLS];
float B[ROWS][COLS];
float C[ROWS];
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
fscanf(in, "%f", &A[i][j]);
}
}
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
fscanf(in, "%f", &B[i][j]);
}
}
for (int i = 0; i < ROWS; i++) {
C[i] = 0;
for (int j = 0; j < ROWS; j++) {
for (int k = 0; k < COLS; k++)
C[i] += A[i][k] * B[j][k];
}
}
for (int i = 0; i < ROWS; i++) {
fprintf(out, "%f\n", C[i]);
}
fclose(in);
fclose(out);
return 0;
}