백준 알고리즘
[Bronze III] 네 번째 점 - 3009
성능 요약
메모리: 13152 KB, 시간: 4 ms
분류
기하학(geometry), 구현(implementation)
문제 설명
세 점이 주어졌을 때, 축에 평행한 직사각형을 만들기 위해서 필요한 네 번째 점을 찾는 프로그램을 작성하시오.
입력
세 점의 좌표가 한 줄에 하나씩 주어진다. 좌표는 1보다 크거나 같고, 1000보다 작거나 같은 정수이다.
출력
직사각형의 네 번째 점의 좌표를 출력한다.
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use std::io;
fn main() {
let mut input_a = String::new();
io::stdin().read_line(&mut input_a).unwrap();
let v: Vec<i32> = input_a
.split_whitespace()
.map(|x| -> i32 { x.parse().unwrap() })
.collect();
let mut input_b = String::new();
io::stdin().read_line(&mut input_b).unwrap();
let v2: Vec<i32> = input_b
.split_whitespace()
.map(|x| -> i32 { x.parse().unwrap() })
.collect();
let mut input_c = String::new();
io::stdin().read_line(&mut input_c).unwrap();
let v3: Vec<i32> = input_c
.split_whitespace()
.map(|x| -> i32 { x.parse().unwrap() })
.collect();
let x1 = v[0];
let y1 = v[1];
let x2 = v2[0];
let y2 = v2[1];
let x3 = v3[0];
let y3 = v3[1];
if x1 == x2 {
if y1 == y2 {
println!("{} {}", x3, y3);
} else if y1 == y3 {
println!("{} {}", x3, y2);
} else {
println!("{} {}", x3, y1)
}
} else if x1 == x3 {
if y1 == y2 {
println!("{} {}", x2, y3);
} else if y1 == y3 {
println!("{} {}", x2, y2);
} else {
println!("{} {}", x2, y1)
}
} else {
if y1 == y2 {
println!("{} {}", x1, y3);
} else if y1 == y3 {
println!("{} {}", x1, y2);
} else {
println!("{} {}", x1, y1)
}
}
}