
c语言编程,函数如何用?
#include<stdio.h>doublef(doublex,doubley){doublea;returna=y-2.0*x/y;}voidmain(){intN;...
#include<stdio.h>
double f(double x,double y)
{ double a;
return a=y-2.0*x/y;
}
void main()
{
int N;double left=0.0,right=1.0,x,y=1.0,h;
double k1,k2,k3,k4;
int i;
h=(right-left)/N;
x=left;
for(i=1;i<N;i++)
{
k1=f(x,y);
k2=f(x+h/2,y+h*k1/2);
k3=f(x+h/2,y+h*k2/2);
k4=f(x+h,y+h*k3);
y=y+(h/6.0)*(k1+2*k2+2*k3+k4);
x=x+h*i;
printf("%lf",k1);
}
} 展开
double f(double x,double y)
{ double a;
return a=y-2.0*x/y;
}
void main()
{
int N;double left=0.0,right=1.0,x,y=1.0,h;
double k1,k2,k3,k4;
int i;
h=(right-left)/N;
x=left;
for(i=1;i<N;i++)
{
k1=f(x,y);
k2=f(x+h/2,y+h*k1/2);
k3=f(x+h/2,y+h*k2/2);
k4=f(x+h,y+h*k3);
y=y+(h/6.0)*(k1+2*k2+2*k3+k4);
x=x+h*i;
printf("%lf",k1);
}
} 展开
2014-12-05
展开全部
就这么用啊,你想怎么用?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询