문제 링크입니다: https://www.acmicpc.net/problem/3009
3009번: 네 번째 점
세 점이 주어졌을 때, 축에 평행한 직사각형을 만들기 위해서 필요한 네 번째 점을 찾는 프로그램을 작성하시오.
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
const int MAX = 3; | |
typedef struct | |
{ | |
int x, y; | |
} Coord; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
Coord coordinates[MAX]; | |
for (int i = 0; i < MAX; i++) | |
{ | |
cin >> coordinates[i].x >> coordinates[i].y; | |
} | |
int x, y; | |
if (coordinates[0].x == coordinates[1].x) | |
{ | |
x = coordinates[2].x; | |
} | |
else if (coordinates[0].x == coordinates[2].x) | |
{ | |
x = coordinates[1].x; | |
} | |
else | |
{ | |
x = coordinates[0].x; | |
} | |
if (coordinates[0].y == coordinates[1].y) | |
{ | |
y = coordinates[2].y; | |
} | |
else if (coordinates[0].y == coordinates[2].y) | |
{ | |
y = coordinates[1].y; | |
} | |
else | |
{ | |
y = coordinates[0].y; | |
} | |
cout << x << " " << y << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 3486번 Adding Reversed Numbers (0) | 2021.05.15 |
---|---|
백준 3460번 이진수 (0) | 2021.05.14 |
백준 3028번 창영마을 (0) | 2021.05.14 |
백준 3029번 경고 (0) | 2021.05.14 |
백준 3034번 앵그리 창영 (0) | 2021.05.14 |