二维数组实验题:按如下公式递归计算矩阵行列式的值:
提示信息:“Please enter matrix size n(1<=n<20):” “Please input matrix line
by line:\n” “matrix a:\n”
**输出格式要求:“Submatrix:\n” “DValue of the Submatrix is %6.1f\n” “%6.1f\t” “result = %f\n”
程序运行结果如下:
Please enter matrix size n(1<=n<20):3
Please input matrix line by line:
1 2 3
4 5 7
8 9 11
matrix a:
1.0 2.0 3.0
4.0 5.0 7.0
8.0 9.0 11.0
(注意:此处有一个空行)
Submatrix:
5.0 7.0
9.0 11.0
DValue of the Submatrix is -8.0
Submatrix:
4.0 7.0
8.0 11.0
DValue of the Submatrix is -12.0
Submatrix:
4.0 5.0
8.0 9.0
DValue of the Submatrix is -4.0
result = 4.000000
下面是代码:
#include <math.h>
#include <stdio.h>
#define CONST 1e-6
#define SIZE 20
void InputMatrix (double a[][SIZE], int n);
double DeterminantValue(double a[][SIZE], int n);
void SubMatrix(double a[][SIZE], double b[][SIZE], int n, int row, int col);
void PrintMatrix(double a[][SIZE], int n);
int main(void)
{
double a[SIZE][SIZE];
int n