-
Notifications
You must be signed in to change notification settings - Fork 6
/
Ders - 1.c
89 lines (74 loc) · 2.07 KB
/
Ders - 1.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <stdio.h>
#include <stdlib.h>
void dizi_yaz(int *dizi, int size){
int i;
for(i=0; i<size; i++)
printf("%4d", *(dizi+i));
printf("\n\n");
// for(i=0; i<size; i++)
// printf("%6d", *(dizi+i));
// printf("\n");
}
void dizi_yaz1(int (*dizi)[2],int size){
int i,j;
for(i=0; i<size; i++){
for(j=0; j<2; j++)
printf("%4d",*(*(dizi+i)+j));
// printf("%4d",dizi[i][j]);
printf("\n");
}
}
void dizi_yaz2(int (*dizi)[3][5], int size){
int i,j,k;
for(i=0; i<size; i++){
for(j=0; j<3; j++){
for(k=0; k<5; k++)
printf("%4d",dizi[i][j][k]);
printf("\n");
}
printf("\n");
}
}
void matris_carpimi(int A[][3], int A_satir, int A_sutun,
int B[][2], int B_satir,int B_sutun,
int C[][2],int C_satir, int C_sutun){
int i,j,k;
if(A_sutun!=B_satir){
printf("Carpim matrislerinin boyutlari uyusmuyor!!!");
return;
}
else if(A_satir!=C_satir || B_sutun!=C_sutun){
printf("Sonuc matrisinin boyutlari carpan matrislere uymuyor!!!\n");
return;
}
else{
for(i=0; i<A_satir; i++)
for(j=0; j<B_sutun; j++){
C[i][j]=0;
for(k=0; k<A_sutun; k++)
C[i][j]=C[i][j]+A[i][k]*B[k][j];
}
}
}
int main(int argc, char** argv) {
int A[]={0,1,12,33,4,5,6,7,8,9};
int B[][5]={{0,1,2,3,4},
{10,877,12,13,14},
{20,21,22,23,24},
{30,31,32,33,34}};
int C[2][3][5]= {{{0,11,2,3,4},
{10,877,12,13,14},
{20,21,22,23,24}},
{{0,1,2,3,4},
{10,877,152,13,14},
{20,21,22,23,274}}};
int AA[][3]={{1,8,1},{2,1,4},{5,1,0},{1,2,3}};
int BB[][2]={{0,1},{2,4},{3,9}};
int CC[4][2];
//dizi_yaz(&C[1][1][1], 7);
// dizi_yaz2(C+1, 1);
matris_carpimi(AA,4,3,BB,3,2,CC,4,2);
dizi_yaz1(CC,4);
//dizi_yaz1(CC,4);
return (EXIT_SUCCESS);
}