// 主对角线法 ,不管是怎么求值,row始终是要往下移 int CalDeterminant( int (*data)[vertexNum|1],// 行列式,下标从1开始 int n// 行列式大小 ) { int r0, r1,row,col; int value; // 反 r0 = 0; for (int i = n; i >= 1; i--) { row = 1; col = i; value = 1; for (int j = 1; j <= n; j++) { value *= arr[row][col]; row++; col--; if (col == 0) col = n; } r0 += value; } // 正 r1 = 0; for (int i = 1; i <= n; i++) { row = 1; col = i; value = 1; for (int j = 1; j <= n; j++) { value *= arr[row][col]; row++; col = (col+1)%(n+1); if (col == 0) col = 1; } r1 += value; } return r1+r0; }