ComplexT
来源:互联网 发布:聚宝盆返奖软件 编辑:程序博客网 时间:2024/06/05 05:03
#include<stdio.h>
int main()
{
float va[]={50.0f,46.0f,40.0f,32.2f,22.5f},temp,a,b,h;
int j,i,n;
a=0;
b=8;
n=2;
h=(b-a)/n;
temp=1/va[0]+1/va[4];
//complex T
for(i=0;i<n-1;++i)
{
j=i+1;
temp=temp+2/va[j];
}
printf("complex T :%f\n",h*temp/2);
//complex simpson
h=4;
temp=1/va[0];
for(i=0;i<=n-1;++i)
{
j=i+1;
temp=temp+4/va[j];
j=j+1;
temp=temp+2/va[j];
}
printf("complex simpson :%f\n",h*temp/6);
return 0;
}
int main()
{
float va[]={50.0f,46.0f,40.0f,32.2f,22.5f},temp,a,b,h;
int j,i,n;
a=0;
b=8;
n=2;
h=(b-a)/n;
temp=1/va[0]+1/va[4];
//complex T
for(i=0;i<n-1;++i)
{
j=i+1;
temp=temp+2/va[j];
}
printf("complex T :%f\n",h*temp/2);
//complex simpson
h=4;
temp=1/va[0];
for(i=0;i<=n-1;++i)
{
j=i+1;
temp=temp+4/va[j];
j=j+1;
temp=temp+2/va[j];
}
printf("complex simpson :%f\n",h*temp/6);
return 0;
}