2022年5月10日 星期二

二長方形重疊區域面積

 def dist(a,b,c,d):

    over = 0

    if b>=d>=a>=c: over=d-a

    elif d>=b>=a>=c : over = b-a

    elif b>=d>=c>=a : over = d-c

    elif d>=b>=c>=a:over = b-c

    else : over=0

    return over

x1,y1,w1,h1 = map(int,input().strip().split())

x2,y2,w2,h2 = map(int,input().strip().split())


xdist = dist(x1,x1+w1,x2,x2+w2)

ydist = dist(y1,y1+h1,y2,y2+h2)

area = xdist*ydist

print(area)

沒有留言:

張貼留言