길이가 서로 다른 A,B,C 세개의 변이 주어지면 이 세 변이 삼각형을 마들 수 있으면 "YES" 아니면 "NO"를 출력
<!DOCTYPE html>
<head>
</head>
<body>
<script>
// 삼각형이 만들어지기 위한 조건 : 짧은 두 직선의 합이 반드시 가장 긴 직선보다 길어야 함
var input = prompt('100이하의 자연수 A,B,C 입력해주세요.');
function triangle(input)
{
let maxValue = input.split(",");
let a = parseInt(maxValue[0]);
let b = parseInt(maxValue[1]);
let c = parseInt(maxValue[2]);
let total = a + b + c;
let result;
if(a < b)
result = b;
else
result = a;
if (result < c)
result = c;
if((total - result) >= result)
alert("YES");
else
alert("NO");
}
triangle(input);
</script>
</body>
</html>
https://github.com/LeeDH-git/algorithm-JS.git
'알고리즘 > 기초' 카테고리의 다른 글
홀수 (0) | 2021.09.30 |
---|---|
최솟값 구하기 (0) | 2021.09.29 |
1부터 N까지의 합 (0) | 2021.09.28 |
연필갯수 (0) | 2021.09.28 |
세 수 중 최솟값 구하기 (0) | 2021.09.28 |