B. Three Angles
Given three angles, determine if it is possible to have a triangle of positive area with these
angles.
Input
The first line of input contains one integer T, the number of test cases (1 ≤ T ≤ 128).
Each of the following T lines contains 3 space-separated integers (0 ≤ θ1, θ2, θ3 ≤ 180). These
integers represent the three angles.
Output
For each test case, print “YES” if it is possible to have a triangle of positive area with angles (θ1,
θ2, θ3) and print “NO” otherwise.
Sample Input Sample Output
3
50 60 70
50 65 80
45 90 45
YES
NO
YES
题意:
给3个角度,判断是否构成三角形。
思路:
判断三个数相加是否等于180,注意不能为0和负数。
#include<stdio.h>
int main()
{
int t,a,b,c;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&a,&b,&c);
if(a+b+c==180&&a>0&&b>0&&c>0)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
}