B. Three Angles

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");
        }
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 最近面试中被问到一个关于列表滚动时NSTimer暂停的问题,回来后查询相关资料发现原来做的app确实存在这么一个问...
    雪中夜归人阅读 923评论 0 1
  • 你舞跳的真好。 你拿了我的铅笔了吗? 儿子的鼻子像我。 那首歌是怎么唱的。 You dance very well...
    半城浮夸阅读 688评论 1 10
  • 我终于来到了 地球上最后一个酒吧 没有人招呼我 我独自开了瓶酒 喝完又开 喝完又开 谁叫你 不早不迟 消失在我爱喝...
    留子尧阅读 238评论 2 2
  • 写在11年11月11日,星期一,我的生日。多想日历的这一天,不在年轮中出现。也多想这一天的时间能延迟到无期限。 秋...
    幸福像朵花儿一样阅读 301评论 0 0
  • 我可能不再爱你,但或许,我还喜欢你。只是,爱的太短,遗忘太久。 你从我的世界打马走过,留我一人兵荒马乱。 林熙和林...
    一只步绘走远了阅读 564评论 7 5