튜토리얼의 DRAWRECT 문제 질문있습니다.

  • msy
    msy

    import java.util.Scanner;

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

    int count = scan.nextInt();
    int x1=0, x2=0, x3=0, y1=0, y2=0, y3=0;

    for(int i=0; i<count; i++){
            x1 = scan.nextInt();
            y1 = scan.nextInt();
            x2 = scan.nextInt();
            y2 = scan.nextInt();
            x3 = scan.nextInt();
            y3 = scan.nextInt();
    
            if(x1 == x2){
                if(y1==y3)
                    System.out.println(x3+" "+(y3+(y2-y1)));
                else
                    System.out.println(x3+" "+(y3-(y2-y1)));
            }
            else if(x1 == x3){
                if(y1==y2)
                    System.out.println((x3+(x2-x1))+" "+y3);
                else
                    System.out.println((x3-(x2-x1))+" "+y3);
            }
            else{
                if(y1==y2)
                    System.out.println(x1+" "+(y1+(y3-y2)));
                else
                    System.out.println(x1+" "+(y1-(y3-y2)));
            }   
        }
    
    }

    }

    약간 코드를 중복으로 구현한 느낌이 있긴 한데.....
    왜 오답으로 나오는지를 모르겠습니다 ㅠㅠ


    9년 전
0개의 댓글이 있습니다.
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.