#include"stdafx.h"#include<stdio.h>#include<stdlib.h>#include<windows.h>#defineNUM 3intFun (intNintA[num][num]);/*function Declaration*/intMain () {inti =0, j =0;/*i,j represents rows and columns, respectively*/ inta[3][3] = { { -,6,2},{6,3,3},{5,9,8} };/*Defining determinant*/printf ("%d\n", Fun (NUM, a)); System ("Pause"); return 0;}/*The following is a recursive function for calculating determinant values*/intFun (intNintA[num][num]) { Static intB[num][num] = {{0} };/*Define array B and initialize*/ inti =0, j =0, sum =0;/*i,j is row and column, sum is the value of the determinant*/ intx =0, C =0, p =0;/*use X to determine the addition and subtraction, c,p as the intermediate variable*/ if(n = =1) returna[0][0]; for(i =0; I < n; i++)/*here Cycle implementation will cofactor type in array b*/ { for(c =0; C < n-1; C++) { for(j =0; J < N-1; J + +) { if(C < i) {/*use C to determine how each line moves*/P=0;/*when P=0, the determinant only shifts to the left, that is, the number of the corresponding first column is eliminated .*/ } Else{/*Otherwise, the determinant shifts left and then moves up.*/P=1; } B[c][j]= a[c + P][j +1]; } } ifI2==0) {/*I+j (at this time j=0, so only i) is even, the addition budget*/x=1; } Else{/*I+j is an odd, subtraction operation*/x= (-1); } Sum+ = a[i][0] * Fun (N-1, b) * x;/*calculate the value of a determinant*/ } returnSum/*returns the value*/}
C-Language for determinant values