该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
{
j ++;
if (j == n) break;
}
if (j == n) break;
gauss (matrix, matrix, k, j, n);
}
}
for (i = 0; i <= n - 1; i ++)
{
temp = resault;
*resault = *temp * matrix[i][i];
}
}
void main( ) //矩阵求逆
{
double **matrix, **M, resault = 1,**adjoint, **inverse, **answer;
int n, i, j, k;
printf("请输入矩阵的阶数:");
scanf("%d", &n);
matrix = (double **)malloc(n * sizeof(double *));
adjoint = (double **)malloc(n * sizeof(double *));
inverse = (double **)malloc(n * sizeof(double *));
answer = (double **)malloc(n * sizeof(double *));
M = (double **)malloc(n * sizeof(double *));
for (i = 0; i < n; i ++)
{
matrix[i] = (double *)malloc(n * sizeof(double));
adjoint[i] = (double *)malloc(n * sizeof(double));
inverse[i] = (double *)malloc(n * sizeof(double));
answer[i] = (double *)malloc(n * sizeof(double));
M[i] = (double *)malloc(n * sizeof(double));
}
printf("请输入矩阵:\n(每个数据用空格隔开,一行输入结束后按回车)\n");
for (i = 0; i <= n - 1; i ++)
{
for (j = 0; j <= n - 1; j ++)
{
scanf("%lf", &matrix[i][j]);
M[i][j] = matrix[i][j];
}
}
for (i = 0; i <= n - 1; i ++)
{
for (j = 0; j <= n - 1; j ++)