积分的题目还是第一次做,直接用到了高数的知识,恩,还有,曲线的方程用顶点式y = a(x-h)^2+l, (h,l) 为顶点
注意精度问题
#include<stdio.h> #include<math.h> double x,y,x2,y2,x3,y3,area; double l,h,a,k,b; double f(double x) {return (a*x*x*x/3)-(a*h+k/2)*x*x+(a*h*h+l-b)*x;} int main() { int t; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf%lf%lf",&x,&y,&x2,&y2,&x3,&y3); h=x;l=y;a=(y2-y)/((x2-x)*(x2-x)); k=(y3-y2)/(x3-x2);b=y2-k*x2; printf("%.2lf\n",f(x3)-f(x2)); } return 0; }