线性方程求解问题
小弟刚学算法,这个程序有一个错误,希望帮忙一下错误如下:--------------------Configuration: GAUSS - Win32 Debug--------------------
Compiling...
GAUSS.CPP
D:\Program Files\新建文件夹\MSDev98\MyProjects\suanfa\GAUSS.CPP(40) : error C2664: 'Gauss' : cannot convert parameter 1 from 'double' to 'double [][11]'
There is no context in which this conversion is possible
Error executing cl.exe.
GAUSS.OBJ - 1 error(s), 0 warning(s)
#include<iostream>
using namespace std;
#define MAX 10
#define ESP 1e-10
void Gauss(double a[MAX][MAX+1])
{
int i=0,j=0,k=0;
double B=0.0, b[MAX];
for(k=0;k<MAX;k++)
{
if(a[k][k]<=ESP)
cout<<"unavailable"<<endl;
else
for(i=k+1;i<MAX;i++)
{
a[i][k]=a[i][k]/a[k][k];//从第二行系数是第一行的倍数
for(j=k;k<MAX+1;k++)
a[i][j]=a[i][j]-(a[i][k]*a[k][j]);//从第二行开始进行消元
}
}
if (a[MAX][MAX]<=ESP)
cout<<"unavailable"<<endl;
else
{
b[MAX]=a[MAX][MAX+1]/a[MAX][MAX];
for(k=MAX-2;k>=0;k--)
{
B=a[k][MAX+1];
for(j=k+1;j<MAX;j++)
B=B-a[k][j]*b[j];
b[k]=B/a[k][k];
}
for(i=0;i<MAX;i++)
cout<<b[i]<<" ";
}
}
void main()
{
double a[3][4]={{1e-10,2,3,1},{-1,3.712,4.623,2},{-2,1.072,5.643,3}};
Gauss(a[3][4]);
}