알고리즘/SWEA
[SWEA] 3456. 직사각형 길이 찾기
hyerann
2019. 5. 5. 18:26
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
www.swexpertacademy.com
직사각형은 같은 길이의 변이 두개씩 있으므로, 같은 길이끼리 짝을 짓고 남은 길이를 답으로 출력했다.
#include <iostream>
#include <ios>
using namespace std;
int length[3];
int getResult();
int main() {
cin.tie(0); ios::sync_with_stdio(0);
int T; cin >> T;
for (int tc = 1; tc <= T; tc++) {
for (int i = 0; i < 3; i++) cin >> length[i];
cout << '#' << tc << ' ' << getResult() << "\n";
}
return 0;
}
int getResult() {
if (length[0] == length[1]) return length[2];
else if (length[0] == length[2]) return length[1];
else return length[0];
}