Is it Triangle ?
Description
Given the lengths of 3 sticks, find out if it is possible to form a triangle of a positive area. (Non-Degenerate Triangle).
Note: Please implement the solution with the help of a function, any other solution will be discarded.
Input
The first line of the input contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.
The first line of each test case contains 3 integers a,b,c (1 ≤ a,b,c ≤ 100) — the lengths of the 3 sticks.
Output
For each test case, print the answer: "Yes" if possible, else "No".
Answer
function validTriangle(a, b, c){
if (a<(b+c) && b<(a+c) && c<(a+b)){
return true;
}
return false;
}
// INPUT
function runProgram(input) {
var arr = input.split("\n");
var cases = Number(arr[0]);
for(var i = 1; i<= cases; i++){
var sides = arr[i].split(" ").map(Number);
var valid = validTriangle(sides[0], sides[1], sides[2]);
if(valid) {
console.log("Yes");
} else {
console.log("No")
}
}
}
Comments
Post a Comment