HDU 1071 The area ——微积分

【题目分析】

    求二次函数和一次函数围成的面积。

    先解方程求出一次函数和二次函数。

    然后积分。

    现在还是不会积分。

【代码】

#include <cstdio>
#include <cstring>
#include <cstdlib>
//#include <cmath>

#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
#include <iostream>
#include <queue>

using namespace std;

#define maxn 20005
#define mlog 16
#define inf (0x3f3f3f3f)

void Finout()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
    #endif
}
 
int Getint()
{
    int x=0,f=1; char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1; ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

int T;
double x1,x2,x3,y1,y2,y3;
double a,b,c,t,k;

int main()
{
	Finout();
	T=Getint();
	while (T--)
	{
		scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
		k=(y3-y2)/(x3-x2);
		t=y3-x3*k;
		a=(y2-y1)/((x1-x2)*(x1-x2));
		b=-x1*2*a;
		c=y1-a*x1*x1-b*x1;
		printf("%.2f
",(a/3*x3*x3*x3+(b-k)/2*x3*x3+x3*(c-t))-(a/3*x2*x2*x2+(b-k)/2*x2*x2+x2*(c-t)));
	}
}

  

原文地址:https://www.cnblogs.com/SfailSth/p/6360264.html