一个问题,谁能帮我快速解决,很感谢!!!!!!!!!
#include<stdio.h>#include<math.h>
#define maxsize 100
int main(void)
{
double a,b,step,x[maxsize],y[maxsize];
double f1(double x,double y);
double f2(double x);
int i,n;
printf("please input step=\n");
scanf("%lf",&step);
printf("please input a= and b=\n");
scanf("%lf %lf",&a,&b);
n=(int)((b-a)/step);
for(i=0;i<=n;i++)
x[i]=a+i*step;
y[0]=0;
for(i=0;i<=n-1;i++)
{
y[i+1]=y[i]+step*f1(x[i],y[i]);
}
for(i=0;i<=n;i++)
{
printf("x[%d]=%lf,y[%d]=%lf,f2=%lf",i,x[i],i,y[i],f2(x[i]));
printf("\n");
}
return 0;
}
double f1(double x,double y)
{
double z;
z=622*sin(314*x)-20*y;
return z;
}
double f2(double x)
{
double z;
z=48827*(exp(-20*x)+10*sin(314*x)/157-cos(314*x))/24749;
return z;
}
第一个输入step=0.001
第二个输入a=0 b=0.01
问题是答案的y[0]=0是正确的
但是y[1]的值应该等于y[2]的值,y[2]=y[3]此时的值,一次类推,y[9]的值应该是y[10]的值,
谁能帮我解决一下啊