Determinant of 3x3
Determinant of 3x3
// determinant by using Sarrus's rule
#include <iostream>
using namespace std;
int main()
{
int A [3][3] = {{5,2,-3},{3,-1,1},{-2,1,-2}};
int det = 0;
int SoP = A[0][0]*A[1][1]*A[2][2] + A[0][1]*A[1][2]*A[2][0] + A[0][2]*A[1][0]+A[2][1] -
A[2][0]*A[1][1]*A[0][2] - A[2][1]*A[1][2]*A[0][0] - A[2][2]*A[1][0]+A[0][1];
// int PoS = A[2][0]*A[1][0]*A[0][2] + A[2][1]*A[1][2]*A[0][0] + A[2][2]*A[1][0]+A[0][1]
cout<<"Determinant = "<<SoP;
return 0;
}
// determinant by using Sarrus's rule
#include <iostream>
using namespace std;
int main()
{
int A [3][3] = {{5,2,-3},{3,-1,1},{-2,1,-2}};
int det = 0;
int SoP = A[0][0]*A[1][1]*A[2][2] + A[0][1]*A[1][2]*A[2][0] + A[0][2]*A[1][0]+A[2][1] -
A[2][0]*A[1][1]*A[0][2] - A[2][1]*A[1][2]*A[0][0] - A[2][2]*A[1][0]+A[0][1];
// int PoS = A[2][0]*A[1][0]*A[0][2] + A[2][1]*A[1][2]*A[0][0] + A[2][2]*A[1][0]+A[0][1]
cout<<"Determinant = "<<SoP;
return 0;
}
No comments: