Determinant of 3x3

February 22, 2019
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;
}

No comments:

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();
Powered by Blogger.