纯数学题,定积分。
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double x1, x2, x3, y1, y2, y3, k, h;
int T, i;
cin >> T;
while (T--)
{
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
k = (y2 - y3) / (x2 - x3);
h = y2 - k*x2;
double a, b, c;
a = (y2 - y1) / ((x2 - x1)*(x2 - x1));
b = -2 * a*x1;
c = y1 - a*x1*x1 - b*x1;
double sum;
sum = a / 3 * (x3*x3*x3 - x2*x2*x2) + (b - k) / 2 * (x3*x3 - x2*x2) + (c - h)*(x3 - x2);
cout << fixed << setprecision(2) << sum << endl;
}
return 0;
}
继续加油。