[백준(Baekjoon)][자바(java)] (4153) 직각삼각형 / 수학 2

728x90

 

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);

		int a[] = new int[3];

		while( true ) {

			for( int i = 0; i < 3; i++ )	
				a[i] = sc.nextInt();

			if( a[0]==0 && a[1]==0 && a[2]==0 )	break;
			
			Arrays.sort(a);
			
			if( (a[0]*a[0]) + (a[1]*a[1]) == (a[2]*a[2]) )
				System.out.println("right");
			else
				System.out.println("wrong");
		}

		sc.close();
	}
}

 

입력 값에 마지막 변의 길이가 가장 크다는 조건이 없어서 배열로 입력받고 정렬을 시행했다

 

반응형