Algorithm/Algospot
[algospot]DRAWRECT
skip
2014. 12. 15. 21:57
문제
https://algospot.com/judge/problem/read/DRAWRECT
직사각형을 이루는 네 점중에 세 점을 입력하면 나머지 점의 좌표를 출력해주는 프로그램을 만들어라~
입력
세점의 좌표
출력
나머지 좌표
풀이
처음 이문제를 풀려고 할때는 세점을 받아서 중복검사를해서~ 풀려고하다가~~
뭔가 복잡해지는것같아서~ 남겨두고
다음문제로 넘어갔다가 ~
다시 풀려고하니까 xor을 쓰면 되겠다고 생각해서 적용했더니 되더라; 그러하다;
package com.tutorial;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class DRAWRECT {
public static void main(String[] args) throws Exception {
int[] x = new int[3];
int[] y = new int[3];
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cnt = Integer.parseInt(br.readLine());
while (cnt-- > 0) {
for (int i = 0; i < 3; i++) {
String[] str = br.readLine().split(" ");
x[i] = Integer.parseInt(str[0]);
y[i] = Integer.parseInt(str[1]);
}
System.out.printf("%d %d\n", x[0] ^ x[1] ^ x[2], y[0] ^ y[1] ^ y[2]);
}
}
}