Inflearn Community Q&A
이렇게 해도 괜찮나요?
Written on
·
199
0
const isItTriangle = (A, B, C) => {
// Step 1: Construct a function that takes three arguments
// Step 2: Compare the sum of two values to one arg
// Step 3: If the sum is greater than the one arg, return true otherwise false
if (A + B > C && A + C > B && B + C > A) {
return 'YES';
} else {
return 'NO';
}
}
console.log('Case 1: ' + isItTriangle(6, 7, 11));
console.log('Case 2: ' + isItTriangle(13, 33, 17));
const answer2 = document.querySelector('#q3');
answer2.append(isItTriangle);bigO코테 준비 같이 해요! javascript
Quiz
세 수 중 최솟값을 찾을 때, if 문만 사용한다면 어떤 방식으로 비교하는 것이 일반적인가요?
세 수를 한 번에 비교하여 가장 작은 수를 바로 찾습니다.
두 수의 최솟값을 먼저 찾고, 그 결과와 나머지 한 수를 비교합니다.
가장 큰 수를 먼저 찾은 후, 남은 두 수 중 작은 값을 찾습니다.
모든 가능한 쌍을 비교하여 가장 작은 값을 찾습니다.





