博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ 2056 Rectangles
阅读量:6096 次
发布时间:2019-06-20

本文共 1430 字,大约阅读时间需要 4 分钟。

Problem Description

Given two rectangles and the coordinates of two points on the diagonals of each rectangle,you have to calculate the area of the intersected part of two rectangles. its sides are parallel to OX and OY .

Input

Input The first line of input is 8 positive numbers which indicate the coordinates of four points that must be on each diagonal.The 8 numbers are x1,y1,x2,y2,x3,y3,x4,y4.That means the two points on the first rectangle are(x1,y1),(x2,y2);the other two points on the second rectangle are (x3,y3),(x4,y4).

Output

Output For each case output the area of their intersected part in a single line.accurate up to 2 decimal places.

Sample Input

1.00 1.00 3.00 3.00 2.00 2.00 4.00 4.00
5.00 5.00 13.00 13.00 4.00 4.00 12.50 12.50

Sample Output

1.00
56.25

题目大意:求两个矩形相交的面积,矩形的边均平行于坐标轴。

import java.util.Scanner;public class Main {    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        while(sc.hasNext()){            double[] x = new double[4];            double[] y = new double[4];            for(int i=0;i
x2||y1>y2){ System.out.println("0.00"); continue; }else{ System.out.printf("%.2f",(x2-x1)*(y2-y1)); System.out.println(); } } } private static double min(double d, double e) { if(d
e){ return d; } return e; }}

转载地址:http://dgwza.baihongyu.com/

你可能感兴趣的文章
Caesar cipher
查看>>
SpringSecurity3.X的remember-me
查看>>
作业2
查看>>
15.二层技术之链路聚合(LACP)-----以太通道
查看>>
不受限字符串函数功能的实现
查看>>
iOS7重磅推新--不断尝试与重新设计的过程
查看>>
指针实现两数交换和指向函数的指针
查看>>
【安全牛学习笔记】手动漏洞挖掘-SQL注入
查看>>
springboot使用jest操作elasticsearch
查看>>
聊聊hystrix的BucketedCounterStream
查看>>
聊聊rocketmq的RollingFileAppender
查看>>
【学习笔记】Android中Service通信
查看>>
java中时间类(util Date)的后延与前推处理
查看>>
数据库的事物隔离级别通俗理解
查看>>
The Descent to C
查看>>
es数据备份和恢复
查看>>
Spring MVC 教程,入门学习,深入分析
查看>>
正则表达式常用表
查看>>
XtraTabControl(DEV中选项卡)分页实现拖拽 效果
查看>>
Java nineteen 网络程序设计 TCP通信
查看>>