기타/백준

백준 C# 4153 직각삼각형

Krapboss 2024. 7. 9. 17:03

 

https://www.acmicpc.net/problem/4153

 

문제

 

주어진 3개의 숫자 가 직각 삼격형인지 판단하는 문제

 

a<b<c일 때,

a^2 + b^2 = c^2

일 경우 직각삼각형

 

해결
internal class E4153 // 직각삼각형
{
    static void Main(string[] args)
    {
        while (true)
        {
            int[] n = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();
            if(n.Sum() == 0 ) { break; }
            Console.WriteLine((n[0] * n[0] == n[1] * n[1] + n[2] * n[2]) ? "right" : "wrong");
        } 
    }
}

 

OrderByDescending로 정렬을 함