#include"stdio.h"
#include"math.h"
#define n 3
void Jacobi(double a[][n],double b[],double tol,double N_max)
main()
{
int i;
int N_max=10;
double tol=1e-6;
double x[n]={0,0,0},y[n]={0,0,0},error[n]={0,0,0};
double a[n][n]={2,-1,1,1,1,1,1,1,-2},b[n]={2,3,0};
double x[n]={0,0,0},y[n]={0,0,0};
Jacobi(a,b,tol,N_max);
}
void Jacobi(double a[][n],double b[],double tol,double N_max)
{
printf("Jacobi !")
int i,j,k;
double m0=0,m1=0,m2=0;
double error[n]={0,0,0};
for(k=1;k<N_max;k++)
{
for(i=0;i<n;i++)
{
m1=0,m2=0;
for(j=0;j<n;j++){m1=m1+a[i][j]*x[j];}
for(j=i+1;j<n;j++){m2=m2+a[i][j]*x[j];}
y[i]=(b[i]-m1-m2)/a[i][i];
printf("第%d步迭代结果为x[%d]=%lf\n",k,i,x[i]);
}
m0=0;
for(i=0;i<n;i++)
{
error[i]=y[i]-x[i];
if(fabs(error[i])>m0
m0=fabs(error[i]);
}
if(m0<tol) break;
}
}
代码实现出现两个错误
missing ';' before identifier 'main'
unexpected end of file found
怎么改?在线等