wa가 뜨는 이유

lhs7715f Reply 6 years 31 weeks ago
1. 예시의 예로 계산을 하면 내접한 경우가 되는데, 이 경우가 왜 inside로 처리가 되는지 이해가 안됩니다. 2. 내접은 inside, 외접은 outside로 처리하도록 해서(문제가 바라는 바와는 다르지만 예시를 적용해서) 짰는데, 계속 wa가 뜹니다ㅠㅠ 그냥 문제가 원하는 대로 해야할지, 아니면 짠 코드가 잘못된건지 알려주세요!!ㅠㅠㅠㅠ흑 import java.util.*; public class Main { public static void main(String args[]) { Scanner scan = new Scanner(System.in); double x1 = scan.nextDouble(); double y1 = scan.nextDouble(); double w1 = scan.nextDouble(); double h1 = scan.nextDouble(); double x2 = scan.nextDouble(); double y2 = scan.nextDouble(); double w2 = scan.nextDouble(); double h2 = scan.nextDouble(); if(Math.abs(x2-x1)+w2/2 < w1/2) { if (Math.abs(y2 - y1) +h2 / 2 <= (h1 / 2)) System.out.println("inside"); else if (Math.abs(y2 - y1)+ h2/2 < (h1 + h2) / 2) System.out.println("attach"); else System.out.println("outside"); } else if(w1 / 2 < Math.abs(x2-x1)+w2/2 && Math.abs(x2-x1)+w2/2 < (w1+w2)/2) { if (h1 / 2 <= Math.abs(y2 - y1) + h2 / 2 && Math.abs(y2 - y1)+ h2/2 <= (h1 + h2) / 2) System.out.println("attach"); else System.out.println("outside"); } else if(w1 / 2 == Math.abs(x2-x1)+w2/2 || Math.abs(x2-x1)+w2/2 == (w1+w2)/2) { if(Math.abs(y2-y1)+h2/2 < h1/2) System.out.println("inside"); else if (Math.abs(y2-y1)+h2/2 == (h1+h2)/2) System.out.println("attach"); else System.out.println("outside"); } else System.out.println("outside"); } }