• toc {:toc}

문제

μ„Έ 점이 μ£Όμ–΄μ‘Œμ„ λ•Œ, 좕에 ν‰ν–‰ν•œ μ§μ‚¬κ°ν˜•μ„ λ§Œλ“€κΈ° μœ„ν•΄μ„œ ν•„μš”ν•œ λ„€ 번째 점을 μ°ΎλŠ” ν”„λ‘œκ·Έλž¨μ„ μž‘μ„±ν•˜μ‹œμ˜€.

μž…λ ₯

μ„Έ 점의 μ’Œν‘œκ°€ ν•œ 쀄에 ν•˜λ‚˜μ”© μ£Όμ–΄μ§„λ‹€. μ’Œν‘œλŠ” 1보닀 ν¬κ±°λ‚˜ κ°™κ³ , 1000보닀 μž‘κ±°λ‚˜ 같은 μ •μˆ˜μ΄λ‹€.

좜λ ₯

μ§μ‚¬κ°ν˜•μ˜ λ„€ 번째 점의 μ’Œν‘œλ₯Ό 좜λ ₯ν•œλ‹€.

좜처:https://www.acmicpc.net/problem/3009

풀이

λ‹¨μˆœ 비ꡐλ₯Ό ν†΅ν•œ 풀이. (더 잘 ν’€ 수 μžˆμ„ 것 같은데…)

xμ’Œν‘œμ—μ„œ κ²ΉμΉ˜μ§€ μ•Šμ€ 것이 res.xμ’Œν‘œ, yμ’Œν‘œμ—μ„œ κ²ΉμΉ˜μ§€ μ•ŠλŠ” 것이 res.yμ’Œν‘œ

#include <iostream>
 
using namespace std;
 
struct Coordinate{
	int x;
	int y;
};
 
int main() 
{
  	Coordinate a, b, c, res;
	cin >> a.x >> a.y;
	cin >> b.x >> b.y;
	cin >> c.x >> c.y;
	
	if((a.x==b.x))
		res.x = c.x;
	else if((a.x==c.x))
		res.x = b.x;
	else if(b.x==c.x)
		res.x = a.x;
	
	if((a.y==b.y))
		res.y = c.y;
	else if((a.y==c.y))
		res.y = b.y;
	else if(b.y==c.y)
		res.y = a.y;
	
	cout << res.x << " " << res.y << endl;
	
	
	return 0;
}