The area 积分

思路就是用顶点式求抛物线的方程,然后再再求出其原函数,积分减去梯形面积即可

 1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <math.h>
4
5 double a, b, c, x1, x2, x3, p1, p2, p3;
6
7 double fun (double x )
8 {
9 return (1.0 / 3 ) * a * ( x - x1 ) * (x - x1 ) * (x - x1 ) + p1 * x;
10 }
11
12 int main( )
13 {
14 int T, i;
15 scanf("%d", &T);
16 while (T--)
17 { // printf("%d\n",T);
18
19 scanf("%lf %lf %lf %lf %lf %lf",&x1, &p1, &x2, &p2, &x3, &p3);
20 a = (p2 - p1) /( (x2 - x1) * (x2 - x1) );
21 b = (p2 + p3 ) * ( x3 - x2 ) / 2.0;
22 c = fun ( x3 ) - fun ( x2 ) - b;
23 printf("%.2lf\n",c);
24 //system("pause");
25 }
26 return 0;
27 }

  

转载于:https://www.cnblogs.com/tangcong/archive/2011/07/20/2111341.html

你可能感兴趣的:(The area 积分)