[SWEA] 직사각형 길이 찾기

문제 보러가기

제한사항

입력으로 직사각형이 불가능한 경우는 주어지지 않는다.

세 자연수의 범위는 a, b, c(1 ≤ a, b, c ≤ 100) 이다.

첫번째 생각

같은 변을 찾고, 남은 숫자를 출력한다.

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
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T= sc.nextInt();
		for(int tc=1; tc<=T; tc++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
		
			int res;
			if( a == b) {
				res = c;
			} else if ( a == c) {
				res = b;
			} else {
				res = a;
			}
			System.out.println("#"+tc+" "+res);
		}
	}
}