intro : 네번째 점을 구하는 아이디어는 x좌표의 값들중 나오지않은 x좌표의 값, y좌표의 값들중 나오지 않은 y좌표의 값이 포인트
문제
세 점이 주어졌을 때, 축에 평행한 직사각형을 만들기 위해서 필요한 네 번째 점을 찾는 프로그램을 작성하시오.
입력
세 점의 좌표가 한 줄에 하나씩 주어진다. 좌표는 1보다 크거나 같고, 1000보다 작거나 같은 정수이다.
출력
직사각형의 네 번째 점의 좌표를 출력한다.
문제 풀이
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input1 = br.readLine().split(" ");
int x1 = Integer.parseInt(input1[0]);
int y1 = Integer.parseInt(input1[1]);
String[] input2 = br.readLine().split(" ");
int x2 = Integer.parseInt(input2[0]);
int y2 = Integer.parseInt(input2[1]);
String[] input3 = br.readLine().split(" ");
int x3 = Integer.parseInt(input3[0]);
int y3 = Integer.parseInt(input3[1]);
int x = x1 == x2 ? x3 : x1 == x3 ? x2 : x1;
int y = y1 == y2 ? y3 : y1 == y3 ? y2 : y1;
System.out.println(x + " " + y);
}
}