本帖最后由 风铃 于 2020-10-4 12:38 编辑
SubMatrix函数完全错了, 修改
- void SubMatrix(double a[][SIZE], double b[][SIZE], int n, int row, int col)
- {
- int i, j, x=0, y=0;
- //抽下去一项,注意判断行和列(continue实现),呵呵。
- for(i=0; i < n; i++){
- if(i == row){
- continue;
- }
- y = 0;
- for(j=0; j < n; j++){
- if(j == col){
- continue;
- }
- b[x][y]=a[i][j];
- y++;
- }
-
- x++;
- }
- }
复制代码
- Please enter matrix size n(1<=n<20):3
- Please input matrix line by line:
- 6 1 1
- 4 -2 5
- 2 8 7
- matrix a:
- 6.0 1.0 1.0
- 4.0 -2.0 5.0
- 2.0 8.0 7.0
- -2.0 5.0
- 8.0 7.0
- DValue of the Submatrix is -54.0
- 4.0 5.0
- 2.0 7.0
- DValue of the Submatrix is 18.0
- 4.0 -2.0
- 2.0 8.0
- DValue of the Submatrix is 36.0
- result = -306.000000
复制代码 |