zoukankan      html  css  js  c++  java
  • (HDOJ2039)三角形

    Problem Description
    给定三条边,请你判断一下能不能组成一个三角形。
     
    Input
    输入数据第一行包含一个数M,接下有M行,每行一个实例,包含三个正数A,B,C。其中A,B,C <1000;
     
    Output
    对于每个测试实例,如果三条边长A,B,C能组成三角形的话,输出YES,否则NO。
     
    Sample Input
    2
    1 2 3
    2 2 2
     
    Sample Output
    NO
    YES
     
     1 #include<stdio.h>
     2 #include<math.h>
     3 #include<ctype.h>
     4 #include<string.h>
     5 
     6 void deal(float a, float b, float c)
     7 {
     8   if(a+b<=c || b+c<=a || a+c<=b)
     9   {
    10       printf("NO\n");
    11   }
    12   else
    13   {
    14       printf("YES\n");
    15   }
    16 }
    17 
    18 void solve()
    19 {
    20     int n;
    21     float a,b,c;
    22     while(scanf("%d",&n)!=EOF)
    23     {
    24         while(n--)
    25         {
    26            scanf("%f %f %f",&a,&b,&c);
    27            deal(a,b,c);    
    28         }
    29     }
    30 }
    31 
    32 
    33 int main()
    34 {
    35   solve();  
    36   return 0;
    37 }
  • 相关阅读:
    IOS整体代码复习一
    IOS复习UIActionSheet&UIAlertView
    IOS复习Plist文件的读取和写入
    IOS复习UITextfield&UILabel
    iOS中判断两个圆是否重叠
    iOS指针回调函数
    ios函数指针
    iOS分区
    ios指针第二天
    iOS指针第一天
  • 原文地址:https://www.cnblogs.com/cpoint/p/3011238.html
Copyright © 2011-2022 走看看