杭电1071题
#include <iostream>
using namespace std;
double return_result(double x1,double x2,double x3,double y1,double a);
int main()
{
int case_num;
double x1,y1;
double x2,y2;
double x3,y3;
double a;
double result1;
double result2;
cin>>case_num;
for(int i=0;i<case_num;i++)
{
cin>>x1>>y1
>>x2>>y2
>>x3>>y3;
a = (y2-y1)/((x2-x1)*(x2-x1));
result1 = return_result(x1,x2,x3,y1,a);
result2 = 1/2.0*(y2+y3)*(x3-x2);
//确定cout的输出格式
//表示不同e记法来写浮点数
cout.setf (ios::fixed);
cout.setf (ios::showpoint);
cout.precision (2);
cout<<(result1-result2)<<endl;
}
return 0;
}
double return_result(double x1,double x2,double x3,double y1,double a)
{
double result;
//千万注意1/3.0,不是1/3
result = (1/3.0*a*x3*x3*x3-a*x1*x3*x3+(a*x1*x1+y1)*x3)-
(1/3.0*a*x2*x2*x2-a*x1*x2*x2+(a*x1*x1+y1)*x2);
return result;
}