1、/ Gauss.cpp : Defines the entry point for the console application./#include “stdafx.h“#include “stdio.h“#include “math.h“int Gauss(double *a, double *b, double *x, int n)/由于此处 A 矩阵传递的是一维数组/ai,j在程序中用 ai*n+j表示,请注意区分int i,j,k,m;double l;double temp;/消去过程for(k=0;k=0;i-)xi=bi;for(j=i+1;jn;j+)xi-=xj*ai*n+
2、j;xi/=ai*n+i;return 1;/1 代表能正确求出结果void main()int i,j;double a44=/A 矩阵0.2368,0.2471,0.2568,1.2671,0.1968,0.2071,1.2168,0.2271,0.1581,1.1675,0.1768,0.1871,1.1161,0.1254,0.1397,0.1490;double b4=1.8471,1.7471,1.6471,1.5471;/b 向量double x4;/未知数 xif (Gauss(*a,b,x,4)!=0)printf(“增广矩阵 A|b 最终形式为n“);for (i=0; i=3; i+)for (j=0; j=3; j+)printf (“%et“,aij);printf (“%en“,bi);printf(“计算结果为n“);for (i=0; i=3; i+)printf(“x(%d)=%en“,i,xi);