Source Code:
#include<stdio.h>
#include<stdlib.h>
int determinant(int** a)
{
return a[0][0] * ((a[1][1]*a[2][2]) - (a[2][1]*a[1][2])) -a[0][1] * (a[1][0] * a[2][2] - a[2][0] * a[1][2]) + a[0][2] * (a[1][0] * a[2][1] - a[2][0] * a[1][1]);
}
int main()
{
int **arr, i, j;
arr = (int*) malloc(sizeof(int) * 3);
for (int i = 0; i < 3; i++)
arr[i] = (int*) malloc(sizeof(int) * 3);
for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) scanf("%d", &arr[i][j]);
printf("%d", determinant(arr));
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int determinant(int** a)
{
return a[0][0] * ((a[1][1]*a[2][2]) - (a[2][1]*a[1][2])) -a[0][1] * (a[1][0] * a[2][2] - a[2][0] * a[1][2]) + a[0][2] * (a[1][0] * a[2][1] - a[2][0] * a[1][1]);
}
int main()
{
int **arr, i, j;
arr = (int*) malloc(sizeof(int) * 3);
for (int i = 0; i < 3; i++)
arr[i] = (int*) malloc(sizeof(int) * 3);
for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) scanf("%d", &arr[i][j]);
printf("%d", determinant(arr));
return 0;
}
Comments
Post a Comment