⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1071 the area.cpp

📁 威士忌的HDU题解.大概有260多题的源码。对于学习非常有好处。
💻 CPP
字号:
/*
1071 The area
Time Limit : 1000 ms  Memory Limit : 32768 K  Output Limit : 1024 K

GUN C++
*/
#include <iostream.h>
#include <math.h>
using namespace std;

#define MAX 10000

int main()
{
    int t,ca,cb;
    double p1x,p1y,p2x,p2y,p3x,p3y,a,b,c,k,d,area,stepx,nowx,nowy1,nowy2;
    cout.setf(ios::fixed);
    cout.precision(2);
    while(cin>>t)
    {
        for(ca=0;ca<t;ca++)
        {
            cin>>p1x>>p1y>>p2x>>p2y>>p3x>>p3y;
            k=(p3y-p2y)/(p3x-p2x);
            d=p3y-k*p3x;
            a=(p2y-p1y)/((p2x-p1x)*(p2x-p1x));
            b=-2*a*p1x;
            c=p1y+a*p1x*p1x;
            area=0;stepx=(p3x-p2x)/MAX;nowx=p2x;
            for(cb=0;cb<MAX;cb++)
            {
                nowx+=stepx;
                nowy1=k*nowx+d;
                nowy2=a*nowx*nowx+b*nowx+c;
                area+=stepx*(nowy2-nowy1);
            }
            cout<<area<<endl;
        }//for ca
    }//while t
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -