直线方程y = k*x + d;
抛物线方程y = a(x-b)^2 + c;
然后对y1- y2求积分
代码如下:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<time.h>
#include<math.h>
#define inf 0x7fffffff
#define eps 1e-9
#define pi acos(-1.0)
#define P system("pause")
using namespace std;
double a,b,c,k,d;
double fun(double x)
{
return a*x*x*x/3 - x*x*(2*a*b+k)/2 + x*(a*b*b-d+c);
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int t;
scanf("%d",&t);
while(t--)
{
double x1,y1,x2,y2,x3,y3;
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
k = (y3-y2)/(x3-x2);
d = y2 - k*x2;
b = x1;
c = y1;
a = (y2-y1)/((x2-x1)*(x2-x1));
printf("%.2lf\n",fabs(fun(x3) - fun(x2)));
}
return 0;
}