请各位学长帮忙看看怎么改这个程序
下面这个程序是用龙格库塔法求解微分方程的,哪位学长能帮忙把它改成用数组形式的,我不太会,想学习一下,我编的这个太繁杂可,谢谢! /*龙格库塔法求解微分方程*/
#include "stdio.h"
#include "math.h"
#define A 0 /*定义初值和步长*/
#define B 0.002
#define C 1
#define D 1
#define E 1
double f(double,double,double,double); /* 定义函数*/
double g(double,double,double,double);
double e(double,double,double,double);
main()
{
double x0=A, h=B,
y01=C, u01=D, v01=E,
j01,j02,j03,j04,k01,k02,k03,k04,l01,l02,l03,l04;
int i,n=10000;
FILE *cfPtr;
if((cfPtr=fopen("luolunzi.dat","w"))==NULL) /*数据要写入的文件*/
printf("File could not be opened\n");
else
{
for (i=1;i <=n;i++)
{ /*套用公式开始计算*/
x0=x0+h;
j01=f(x0,y01,u01,v01);
k01=g(x0,y01,u01,v01);
l01=e(x0,y01,u01,v01);
j02=f(x0+h/2.0,y01+h/2.0*j01,u01+h/2.0*k01,v01+h/2.0*l01);
k02=g(x0+h/2.0,y01+h/2.0*j01,u01+h/2.0*k01,v01+h/2.0*l01);
l02=e(x0+h/2.0,y01+h/2.0*j01,u01+h/2.0*k01,v01+h/2.0*l01);
j03=f(x0+h/2.0,y01+h/2.0*j02,u01+h/2.0*k02,v01+h/2.0*l02);
k03=g(x0+h/2.0,y01+h/2.0*j02,u01+h/2.0*k02,v01+h/2.0*l02);
l03=e(x0+h/2.0,y01+h/2.0*j02,u01+h/2.0*k02,v01+h/2.0*l02);
j04=f(x0+h,y01+h*j02,u01+h*k02,v01+h*l02);
k04=g(x0+h,y01+h*j02,u01+h*k02,v01+h*l02);
l04=e(x0+h,y01+h*j02,u01+h*k02,v01+h*l02);
y01=y01+h/6.0*(j01+2.0*j02+2.0*j03+j04);
u01=u01+h/6.0*(k01+2.0*k02+2.0*k03+k04);
v01=v01+h/6.0*(l01+2.0*l02+2.0*l03+l04);
printf("%15.7f\t%15.7f\t%15.7f\t\n",x0,y01,u01,v01);
fprintf(cfPtr,"%15.7f\t%15.7f\t%15.7f\t\n",x0,y01,u01,v01);
}
fclose(cfPtr);
}
}
double f(double s1,double q1,double u1,double r1) /*定义的微分方程*/
{
double z1;
z1=-10*q1+(10*u1);
return z1;
}
double g(double s2,double q2,double u2,double r2)
{
double z2;
z2=28*q2-u2-q2*r2;
return z2;
}
double e(double s3,double q3,double u3,double r3)
{
double z3;
z3=(-8/3)*r3+q3*u3;
return z3;
}