sum +=(a0 + a1*cos(x*w) + b1*sin(x*w) + a2*cos(2*x*w) + b2*sin(2*x*w)+ a3*cos(3*x*w) + b3*sin(3*x*w) +
a4*cos(4*x*w)+ b4*sin(4*x*w) + a5*cos(5*x*w) + b5*sin(5*x*w)
+ a6*cos(6*x*w) + b6*sin(6*x*w) + a7*cos(7*x*w)
+ b7*sin(7*x*w) + a8*cos(8*x*w) + b8*sin(8*x*w))/sqrt(841.9468*k)*exp((0.25(t-x)-16.75)/(268*k))*0.25*t/N;
这里有错误 exp函数中的参数 0.25(t-x) 应该改写成 0.25*(t-x) 这样就行了
#include
#include
#define N 10000000
void main()
{
double sum=0,a0 =2.756,a1 =-2.651,b1 =3.558,a2 =-1.427,
b2 =-2.726,a3=1.885,b3 =-0.2461,a4 =-0.1469,
b4 =1.037,a5 =-0.5039,b5 =-0.1792,a6 =0.1044,
b6 =-0.2081,a7 =0.07508,b7 =0.06699,a8 =-0.03931,
b8 =-0.007734,w =0.06891;
int i=0;/*初始化变量*/
float t,k,x;
scanf("%f%f",&t,&k);
x=i/N*t;
for(i=0; i
sum +=(a0 + a1*cos(x*w) + b1*sin(x*w) + a2*cos(2*x*w) + b2*sin(2*x*w)+ a3*cos(3*x*w) + b3*sin(3*x*w) +
a4*cos(4*x*w)+ b4*sin(4*x*w) + a5*cos(5*x*w) + b5*sin(5*x*w)
+ a6*cos(6*x*w) + b6*sin(6*x*w) + a7*cos(7*x*w)
+ b7*sin(7*x*w) + a8*cos(8*x*w) + b8*sin(8*x*w))/sqrt(841.9468*k)*exp((0.25*/*丢掉了**/(t-x)-16.75)/(268*k))*0.25*t/N;
}
printf("%lf",sum);
}
你这个写的很复杂,我只帮找语法错误。
0.25(t-x) 改为 0.25 * (t-x)