四阶adams显示方法c语言程序,显式四阶Adams方法 代码中出现subscript requires array or pointer type问题,是什么意思?...

显式四阶Adams方法 代码中出现subscript requires array or pointer type问题,是什么意思?0

dcebd7a0de6265b6ccae5ead692f1eab.pngwzx12232015.07.25浏览53次分享举报

#include"stdio.h"

#include"math.h"

#include"iostream.h"

#include"iomanip.h"

double f(double x,double y)

{

return -x*y*y;

}

void main()

{

int n,i;

double h,k1,k2,k3,k4;

n=10;

double *x=new double [n+1];

double *y=new double [n+1];

h=1.0/n;

y[0]=2;

for(i=0;i<=n;i++)

{

x[i]=i*h;

if(i<4)

{

k1=f(x[i],y[i]);

k2=f(x[i]+h/2,y[i]+k1*h/2);

k3=f(x[i]+h/2,y[i]+k2*h/2);

k4=f(x[i]+h,y[i]+k3*h);

y[i+1]=y[i]+(k1+2*k2+2*k3+k4)*h/6;

cout<

}

else

{

y[i]=y[i-1]+h*(55*f[x[i-1],y[i-1]]-59f[x[i-2],y[i-2]]+37*f[x[i-3],y[i-3]]-9*f[i-4],y[i-4])/24;

cout<

}

}

}

else

{

y[i]=y[i-1]+h*(55*f[x[i-1],y[i-1]]-59f[x[i-2],y[i-2]]+37*f[x[i-3],y[i-3]]-9*f[i-4],y[i-4])/24;

cout<

}这个部分有问题,但我看不出来!!!!

D:\1\1.cpp(33) : error C2109: subscript requires array or pointer type

D:\1\1.cpp(33) : error C2297: '*' : illegal, right operand has type 'double (__cdecl *)(double,double)'

D:\1\1.cpp(33) : error C2059: syntax error : 'bad suffix on number'

D:\1\1.cpp(33) : error C2146: syntax error : missing ')' before identifier 'f'

D:\1\1.cpp(33) : error C2059: syntax error : ')'

执行 cl.exe 时出错.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值