Triangle With Angle:
Problem Description:
You're given the
three angles a, b, and c respectively.
Now check if these three angles can form a valid triangle with an area greater
than 0 or not. Print "YES"(without quotes) if
it can form a valid triangle with an area greater than 0, otherwise
print "NO" (without
quotes).
Input:
·
First-line will contain three numbers a, b, and c separated by
space.
Output:
Print "YES"(without quotes) if
these sides can form a valid triangle, otherwise, print "NO" (without
quotes).
Constraints
· 0≤a,b,c≤180
Sample Input 1:
20 40 120
Sample Output 1:
YES
Sample Input 2:
100 18 42
Sample Output 2:
NO
EXPLANATION:
·
In the first example, angles set (20, 40, 120) can form a triangle with
an area greater than 0.
·
In the second example, angles set (100, 18, 42) will never form a valid
triangle.
2 Comments
sir ye a>0 b>0 c>0 kyo likha hai
ReplyDeletehame to area find karna hai vo check karna hai ki vo greater than 0 ho
Logic to check triangle validity if angles are given
DeleteTake angles from users and store in variables say a, b, c.
Now,
Check if(a+b+c == 180) then, triangle can be formed otherwise not.
Note- *** In addition, make sure angles are greater than 0 i.e. check condition for angles if(angle1 > 0 && angle2 > 0 && angle3 > 0).
angles 0 se greater hona chahiye isley check kiya hai aur sum of angles 180 hona chahiye tabhi triangle valid hoga .
i hope you understand.