求非线性方程,其中有2个系数为一维数组,程序运行后答案不对
#include "math.h"
#include "stdio.h"
#include "7dhrt.c"
#define N 5
main()
{ int i,j,n;
int m=6;
double x[N][6];
double dhrtf(double);
n=dhrt(-2.0,5.0,0.2,0.000001,x,m,dhrtf);
printf("M=%d\n",n);
for(j=0;j<N;j++)
{
for (i=0; i<=n-1; i++)
printf("x(%d)(%d)=%13.7e\n",j,i,x[j][i]);
printf("\n");
}
}
double dhrtf(double x)
{
double z[5];
int i;
int con[5]={5,5,5,5,5};
int cons[5]={20,20,20,20,20};
for(i=0;i<N;i++)
z[i]=(((((x-con[i])*x+3.0)*x+1.0)*x-7.0)*x+7.0)*x-cons[i];
return(z[i]);
}