急救!二维数组array size too large in function main怎么办?
#include"stdlib.h"void rkt1(double t,double y[],int n,double h,int k,long double z[],void(*f)())
{int i,j,l;
double a[4],tt,*b,*d;
b=malloc(n*sizeof(double));
d=malloc(n*sizeof(double));
a[0]=h/2.0;a[1]=a[0];a[2]=h;a[3]=h;
for(i=0;i<=n-1;i++) z[i*k]=y[i];
for(l=1;l<=k-1;l++)
{(*f)(t,y,n,d);
for(i=0;i<=n-1;i++)b[i]=y[i];
for(j=0;j<=2;j++)
{for(i=0;i<=n-1;i++)
{y[i]=z[i*k+l-1]+a[j]*d[i];
b[i]=b[i]+a[j+1]*d[i]/3.0;
}
tt=t+a[j];
(*f)(tt,y,n,d);
}
for(i=0;i<=n-1;i++)
y[i]=b[i]+h*d[i]/6.0;
for(i=0;i<=n-1;i++)
z[i*k+l]=y[i];
t=t+h;
}
free(b);free(d);
return;
}主程序为;#include <stdio.h>
#include<rkt1.c>
#include<math.h>
main()
{int i,j;
double t,h,y[3],z[3][2501];
void rkt1f(double,double[],int,double[]);
y[0]=-1.0;y[1]=0.0;y[2]=1.0;
t=0.0;h=0.1;
rkt1(t,y,3,h,2501,z,rkt1f);
printf("\n");
for(i=0;i<=2500;i++)
{t=i*h;
printf("t=%5.2f\n",t);
for(j=0;j<=2;j++)
printf("y(%d)=%e ",j,z[j][i]);
printf("\n");
}
}
void rkt1f(double t,double y[],int n,double d[])
{t=t;n=n;
d[0]=y[1];
d[1]=(0.3+9.0*y[2]*y[2])*sin(y[0])*cos(y[0])-(0.3+9.8/1.5)*sin(y[0])-0.4*y[0];
d[2]=(1.1*cos(y[0])-0.3)/1.2-0.8*sin(1.0*t);
return;
}
运算后出现array size too large in function main怎么解决?