思路:ax^2+bx+c=y;
kx+m=y;
∫(ax^2+bx+c-kx-m)dx;x2<=x<=x3;
用x1,y1,x2,y2,x3,y3表示里面的未知量。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;cin>>t;
while(t--)
{
double x1,y1;cin>>x1>>y1;
double x2,y2;cin>>x2>>y2;
double x3,y3;cin>>x3>>y3;
double a,b,c,k,m;
a=((y1-y2)/(x1-x2)-(y2-y3)/(x2-x3))/(x1-x3);
b=(y1-y2)/(x1-x2)-a*(x1+x2);
c=y1-a*x1*x1-b*x1;
k=(y3-y2)/(x3-x2);
m=y3-k*x3;
double res1=a/3*pow(x3,3)+(b-k)/2*pow(x3,2)+(c-m)*x3;
double res2=a/3*pow(x2,3)+(b-k)/2*pow(x2,2)+(c-m)*x2;
double res=res1-res2;
printf("%.2lf\n",res);
}
return 0;
}