博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The area 积分
阅读量:4349 次
发布时间:2019-06-07

本文共 804 字,大约阅读时间需要 2 分钟。

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

1 #include 
2 #include
3 #include
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

你可能感兴趣的文章