[恢]hdu 2056
生活随笔
收集整理的這篇文章主要介紹了
[恢]hdu 2056
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2011-12-15 05:02:51
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2056
題意:給2個矩陣的對角線坐標,求相交面積。計算幾何。
代碼:
# include <stdio.h>double max(double a, double b){return a>b?a:b;}
double min(double a, double b){return a<b?a:b;}
double gao(double a, double b, double c, double d)
{
double x = max(a,c) ;
double y = min(b,d) ;
y -= x ;
return max(y,0) ;
}
int main ()
{
double t[2], b[2], l[2], r[2] ;
double x1,y1,x2,y2,x3,y3,x4,y4 ;
while (~scanf ("%lf%lf%lf%lf%lf%lf%lf%lf",
&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4))
{
t[0] = min(y1,y2) ;
t[1] = min(y3,y4) ;
b[0] = max(y1,y2) ;
b[1] = max(y3,y4) ;
l[0] = min(x1,x2) ;
l[1] = min(x3,x4) ;
r[0] = max(x1,x2) ;
r[1] = max(x3,x4) ;
printf ("%.2lf\n", gao(t[0],b[0],t[1],b[1]) *
gao(l[0],r[0],l[1],r[1])) ;
}
return 0 ;
}
轉載于:https://www.cnblogs.com/lzsz1212/archive/2012/01/06/2314703.html
總結
以上是生活随笔為你收集整理的[恢]hdu 2056的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 编程的《九句真言》(ZT)
- 下一篇: 斐波那契数列算法分析