国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Java > 正文

HDU 2056 JAVA

2019-11-06 07:21:07
字體:
供稿:網(wǎng)友

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 cin = new Scanner(System.in); while (cin.hasNext()) { double t; double sum = 0.0; double x1 = cin.nextDouble(); double y1 = cin.nextDouble(); double x2 = cin.nextDouble(); double y2 = cin.nextDouble(); double x3 = cin.nextDouble(); double y3 = cin.nextDouble(); double x4 = cin.nextDouble(); double y4 = cin.nextDouble(); if (x1 > x2) { t = x1; x1 = x2; x2 = t; } if (y1 > y2) { t = y1; y1 = y2; y2 = t; } if (x3 > x4) { t = x3; x3 = x4; x4 = t; } if (y3 > y4) { t = y3; y3 = y4; y4 = t; } x1 = max(x1, x3); x2 = min(x2, x4); y1 = max(y1, y3); y2 = min(y2, y4); if (x1 > x2 || y1 > y2) { System.out.println("0.00"); } else { sum = (x2 - x1) * (y2 - y1); System.out.printf("%.2f", sum); System.out.println(); } } } private static double min(double x2, double x4) { if (x2 < x4) return x2; else return x4; } private static double max(double x1, double x3) { if (x1 > x3) return x1; else return x3; }}
上一篇:HDU 2057 JAVA

下一篇:HDU 2055 JAVA

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 海丰县| 扶余县| 冷水江市| 柘城县| 望江县| 娄烦县| 江都市| 新和县| 宜兰市| 翼城县| 方正县| 宁明县| 崇州市| 体育| 水富县| 城口县| 金秀| 太湖县| 珠海市| 波密县| 达拉特旗| 凤山市| 固原市| 永平县| 海南省| 石楼县| 体育| 利津县| 大新县| 平阴县| 和平县| 淮滨县| 二手房| 江永县| 湖南省| 历史| 镇原县| 特克斯县| 吉林市| 海伦市| 抚松县|