삼각형 판별하기

Namlulu·2021년 11월 3일
0

알고리즘

목록 보기
2/28
const prompt = require('prompt-sync')();
const numbers = prompt('Input num : ');

const [a, b, c] = numbers
  .split(' ')
  .map((item) => Number(item))
  .sort((a, b) => a - b);

if (a + b > c) {
  console.log('YES');
} else {
  console.log('No');
}

=> 가장 긴 변을 찾고, 나머지 두 변의 길이가 가장 긴 변보다 크면 무조건 그릴 수 있다.

profile
Better then yesterday

0개의 댓글