import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter r1's center x-, y-coordinates, width, and height: ");
         double x1 = input.nextDouble();
         double y1 = input.nextDouble();
         double width1 = input.nextDouble();
         double height1 = input.nextDouble();

         System.out.print("Enter r2's center x-, y-coordinates, width, and height: ");
         double x2 = input.nextDouble();
         double y2 = input.nextDouble();
         double width2 = input.nextDouble();
         double height2 = input.nextDouble();

         input.close();

         boolean isInside = false;

         if((x1 - width1 / 2 >= x2 - width2 / 2) && (x1 + width1 / 2 <= x2 + width2 / 2) &&
             (y1 - height1 / 2 >= y2 - height2 / 2) && (y1 + height1 / 2 <= y2 + height2 / 2))
         {
             System.out.println("r1 is inside r2");
             isInside = true;
         }
         else if((x2 - width2 / 2 >= x1 - width1 / 2) && (x2 + width2 / 2 <= x1 + width1 / 2) &&
             (y2 - height2 / 2 >= y1 - height1 / 2) && (y2 + height2 / 2 <= y1 + height1 / 2))
         {
             System.out.println("r2 is inside r1");
             isInside = true;
         }

         if(!isInside)
         {
             if(x1 >= x2)
             {
                 if(y1 >= y2)
                 {
                     if((x1 - width1 / 2 >= x2 + width2 / 2) && (y1 - width1 / 2 >= y2 + width2 / 2))
                         System.out.println("r2 does not overlap r1");
                     else
                         System.out.println("r2 overlaps r1");
                 }
                 else
                 {
                     if((x1 - width1 / 2 >= x2 + width2 / 2) && (y1 + width1 / 2 <= y2 - width2 / 2))
                         System.out.println("r2 does not overlap r1");
                     else
                         System.out.println("r2 overlaps r1");
                 }
             }
             else
             {
                 if(y1 >= y2)
                 {
                     if((x1 + width1 / 2 <= x2 - width2 / 2) && (y1 - width1 / 2 >= y2 + width2 / 2))
                         System.out.println("r2 does not overlap r1");
                     else
                         System.out.println("r2 overlaps r1");
                 }
                 else
                 {
                     if((x1 + width1 / 2 <= x2 - width2 / 2) && (y1 + width1 / 2 <= y2 - width2 / 2))
                         System.out.println("r2 does not overlap r1");
                     else
                         System.out.println("r2 overlaps r1");
                 }
             }
         }
     }
 }

HW3.28的更多相关文章

  1. 28个你必须知道的HTML5的新特性,技巧以及技术

    崭新新的页面布局 传统的: HTML5: 1. 新的Doctype 尽管使用<!DOCTYPE html>,即使浏览器不懂这句话也会按照标准模式去渲染 2. Figure元素 用<f ...

  2. CSharpGL(28)得到高精度可定制字形贴图的极简方法

    CSharpGL(28)得到高精度可定制字形贴图的极简方法 回顾 以前我用SharpFont实现了解析TTF文件从而获取字形贴图的功能,并最终实现了用OpenGL渲染文字. 使用SharpFont,美 ...

  3. 来,一起让我们越来越懒,面向CSS、JS未来编程。(9.28已更新)

    2016.10.29更新 本文存在大量的错误,仅供参考. 不知不觉在前端领域马上一个年头就要过去了,然而再看看自己的代码,果然够烂,那么为什么代码一直没有用面向对象的思维去写CSS呢?首先有两点:一点 ...

  4. MySQL报错:Got error 28 from storage engine

    今天碰到数据库出错: Got error 28 from storage engine 查了一下,数据库文件所在的盘应该没事,应该是数据库用的临时目录空间不够 问题原因: 磁盘临时空间不够导致. 解决 ...

  5. [.net 面向对象程序设计进阶] (28) 结束语——告别2015

    [.net 面向对象程序设计进阶] (28) 结束语——告别2015 <.net面向对象程序设计进阶>这一系列文章写了太长的时间了,大概有半年没写,在年底又一口气写了好几篇.在整个过程中目 ...

  6. 背水一战 Windows 10 (28) - 控件(文本类): TextBox, PasswordBox

    [源码下载] 背水一战 Windows 10 (28) - 控件(文本类): TextBox, PasswordBox 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) T ...

  7. 10月28日PHP基础知识测试题

    本试题共40道选择题,10道判断题,考试时间1个半小时 一:选择题(单项选择,每题2分): 1. LAMP具体结构不包含下面哪种(A) A:Windows系统 B:Apache服务器 C:MySQL数 ...

  8. CentOS6.3编译安装Nginx1.4.7 + MySQL5.5.25a + PHP5.3.28

    [准备工作] #在编译安装lnmp之前,首先先卸载已存在的rpm包. rpm -e httpd rpm -e mysql rpm -e php yum -y remove httpd yum -y r ...

  9. 记 Mac Pro 系统升级后,编译安装 PHP-5.6.28 / PHP-7.0 报错修复过程

    买 Mac Pro 的时候,系统为 OS X 10.11.5,编译 PHP-5.6.21 的时候,也遇到一些坑,安装过程记录如下: Mac Pro 编译安装 PHP 5.6.21 及 问题汇总 后来, ...

随机推荐

  1. Vijos p1165 火烧赤壁 离散化+单调栈

    题目链接:https://vijos.org/p/1165 题意:输入n(n <= 20,000)段线段的端点,问所有线段的长度总和为多少? input: -1 1 5 11 2 9 outpu ...

  2. 【BZOJ】1001: [BeiJing2006]狼抓兔子 Dinic算法求解平面图对偶图-最小割

    1001: [BeiJing2006]狼抓兔子 Description 左上角点为(1,1),右下角点为(N,M)(上图中N=4,M=5).有以下 三种类型的道路 1:(x,y)<==>( ...

  3. iOS8上放大缩小的动画

    CGAffineTransformMakeScale这个方法我们以前经常使用,但是在IOS8上出现问题了 [UIView animateWithDuration:0.3 animations:^{ b ...

  4. hdu 1540 Tunnel Warfare (区间线段树(模板))

    http://acm.hdu.edu.cn/showproblem.php?pid=1540 Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others) ...

  5. caffe之(五)loss层

    在caffe中,网络的结构由prototxt文件中给出,由一些列的Layer(层)组成,常用的层如:数据加载层.卷积操作层.pooling层.非线性变换层.内积运算层.归一化层.损失计算层等:本篇主要 ...

  6. js二级下拉菜单

    看似简单的一个菜单,确需要不少的知识点 1. getByClass getElementsByClassName 已经有大部分现代浏览器支持了,只有ie6,ie7,ie8是不支持的.所以对ie6,7, ...

  7. round(x[, n]) : 四舍五入

    >>> round(12.3) 12.0 >>> round(12.5) 13.0 >>> round(12.36) 12.0 >>& ...

  8. HDU 2370 Convert Kilometers to Miles

    点我看题目 题意 : 按照题目给定的规则将公里转化成英里,就是每个数都可以用斐波那契数列里的数表示,每个数都有一个编码,21可以表示成(1,0,0,0,0,0,0) ,13可以表示成(1,0,0,0, ...

  9. vs2012+cmake+opencv+opencv unable to find a build program corresponding to "Visual Studio 12 Win64". CMAKE_MAKE_PROGRAM is not set

    搜索了下,说什么的都有! 一,提示找不到 cmake-2.8.12.1 的 modles 卸载了cmake后发现 cmd 中的 cmake --version 还是 2.8.11.1 找到是我的cyg ...

  10. UVA 558 Wormholes

    要问是否存在一个总权重为负数的环,用dfs即可解决. time:33ms #include <cstdio> #include <cstring> #define N 3000 ...