-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkofakhesap2x2.c
More file actions
31 lines (26 loc) · 986 Bytes
/
kofakhesap2x2.c
File metadata and controls
31 lines (26 loc) · 986 Bytes
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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <sys/wait.h>
int main()
{
int recivedMatrix[2][2]; // alinan 2x2 dizi
int recivedValue = 0; // alinan satir/sutun elemanı
int po = 0; //ust
int detRes = 0; //determinant sonucu
int res = 0; // yazilacak sonuc
read(3 , &recivedValue , sizeof(int)); //satir/sutun degerini oku
read(3 , &recivedMatrix , 4*sizeof(int)); //oluşturulan 2x2 matrisi oku
read(3 , &po , sizeof(int)); //satir+sutun oku
detRes = (recivedMatrix[0][0]*recivedMatrix[1][1]) - (recivedMatrix[0][1]*recivedMatrix[1][0]); //2x2 matis determinantını hesapla
int minusPow = 1; //eksi arı ifade icin
int it = 0;
for(it = 0; it < po ; it++){
minusPow = minusPow*(-1);
}
res = minusPow*recivedValue*detRes; //sonucu hesapla
write(4,&res,sizeof(int)); // sonucu pipe a yaz
return 0;
}