标签:
题意:求阴影部分面积。
析:没什么可说的,就是一个普通的定积分。
代码如下:
#include <cstdio> #include <iostream> using namespace std; int main(){ int T; cin >> T; double x0, y0, x1, y1, x2, y2, k, b, a, c, h, s; while(T--){ scanf("%lf %lf %lf %lf %lf %lf",&x0, &y0, &x1, &y1, &x2, &y2); k = (y2-y1) / (x2-x1); b = y1 - k*x1; h = x0; c = y0; a = (y1-c) / ((x1-h)*(x1-h)); s = (a*x2*x2*x2/3-(2*a*h+k)*x2*x2/2+(a*h*h+c-b)*x2)-(a*x1*x1*x1/3-(2*a*h+k)*x1*x1/2+(a*h*h+c-b)*x1); printf("%.2lf\n", s); } return 0; }
标签:
原文地址:http://www.cnblogs.com/dwtfukgv/p/5604880.html