치춘짱베리굿나이스
[백준] 3009 본문
네 번째 점
문제
세 점이 주어졌을 때, 축에 평행한 직사각형을 만들기 위해서 필요한 네 번째 점을 찾는 프로그램을 작성하시오.
입력
세 점의 좌표가 한 줄에 하나씩 주어진다. 좌표는 1보다 크거나 같고, 1000보다 작거나 같은 정수이다.
출력
직사각형의 네 번째 점의 좌표를 출력한다.
풀이
const fourth = () => {
  let input = require("fs")
    .readFileSync("/dev/stdin")
    .toString()
    .trim()
    .split("\n")
    .map((n) => n.split(" ").map(Number));
  const x =
    input[0][0] === input[1][0]
      ? input[2][0]
      : input[0][0] === input[2][0]
      ? input[1][0]
      : input[0][0];
  const y =
    input[0][1] === input[1][1]
      ? input[2][1]
      : input[0][1] === input[2][1]
      ? input[1][1]
      : input[0][1];
  console.log(`${x} ${y}`);
};
fourth();
반성회
.
'Javascript + Typescript > 자바스크립트로 알고리즘풀기' 카테고리의 다른 글
| [백준] 4948 (0) | 2022.02.13 | 
|---|---|
| [백준] 11653 (0) | 2022.02.13 | 
| [백준] 2581 (0) | 2022.02.13 | 
| [백준] 1929 (0) | 2022.02.11 | 
| [백준] 9020 (0) | 2022.02.11 | 
			  Comments