定积分求面积

http://acm.hdu.edu.cn/showproblem.php?pid=1071

#include<stdio.h>
#include<string.h>
int main()
{
    //freopen("in.txt","r",stdin);
    int t;
    scanf("%d",&t);
    while(t--)
    {
        double x1,y1,x2,y2,x3,y3;
        double k,t,a,b,c;
        scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
        k=(y3-y2)/(x3-x2);
        t=y3-k*x3;
        a=(y2-y1)/((x2-x1)*(x2-x1));
        b=-2*a*x1;
        c=y1+a*x1*x1;
        double s=a/3*(x3*x3*x3-x2*x2*x2)+(b-k)/2*(x3*x3-x2*x2)+(c-t)*(x3-x2);
        printf("%.2lf\n",s);
    }
    return 0;
}

 

posted @ 2014-05-24 11:55  清风旋叶  阅读(286)  评论(0编辑  收藏  举报