This repository has been archived by the owner on Jan 5, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathvyL3.c
74 lines (59 loc) · 1.49 KB
/
vyL3.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
70
71
72
73
74
#include <stdio.h>
#define SATIR 4
#define SUTUN 4
int main()
{
FILE *p = NULL;
int mat1[SATIR][SUTUN];
int mat2[SATIR][SUTUN];
int sonuc[SATIR][SUTUN];
char *okunacakdosya = "matrisler.txt";
char *yeni = "sonuc.txt";
int i, j,k,l;
if((p = fopen("matrisler.txt", "r")) != NULL){
for(i = 0; i < SATIR; i++){
for(j = 0; j < SUTUN; j++){
fscanf(p, "%d", &mat1[i][j]);
printf("%d ", mat1[i][j]);
}
printf("\n");
}
for(int i=0;i<16;i++){
int *p=mat1[0];
printf("%d",p[i]);
}
printf("\n");
for(k = 0; k < SATIR; k++){
for(l = 0; l < SUTUN; l++){
fscanf(p, "%d", &mat2[k][l]);
printf("%d ", mat2[k][l]);
}
printf("\n");
}
for(int i=0;i<16;i++){
int *k=mat2[0];
printf("%d",k[i]);
}
}else{
printf("%s dosyasi bulunamadi!", okunacakdosya);
}
fclose(p);
printf("\n");
FILE *dosya1;
dosya1 = fopen("sonuc.txt","w");
for(i=0;i<SATIR;i++){
for(j=0;j<SUTUN;j++){
int toplam=0;
for(k=0;k<4;k++){
toplam+=mat1[i][k]*mat2[k][j];
}
sonuc[i][j]=toplam;
fprintf(dosya1,"%4d",sonuc[i][j]);
printf("%4d",sonuc[i][j]);
}
fprintf(dosya1,"\n");
printf("\n");
}
fclose(dosya1);
return 0;
}