zoukankan      html  css  js  c++  java
  • hdu2039java

    三角形

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 69908    Accepted Submission(s): 23479


    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

    /*import java.util.*;
    class Main{
    public static void main(String args[])
    {Scanner cin=new Scanner(System.in);
    int n=cin.nextInt();
    while(n-->0)
    {double []a=new double[3];
    double t;
    for(int i=0;i<3;i++)
    a[i]=cin.nextDouble();
    for(int i=0;i<2;i++)
    {for(int j=i+1;j<3;j++)
    {if(a[i]>a[j])
    {t=a[i];
    a[i]=a[j];
    a[j]=t;
    }
    }
    }
    if(a[0]+a[1]>a[2]&&a[2]-a[0]<a[1])
    System.out.println("YES");
    else
    System.out.println("NO");
    }
    }
    }*/
    import java.util.*;
    class Main{
    public static void main(String args[])
    {Scanner cin=new Scanner(System.in);
    int n=cin.nextInt();
    while(n-->0)
    {double a,b,c;
    a=cin.nextDouble();
    b=cin.nextDouble();
    c=cin.nextDouble();
    if(a+b>c&&b+c>a&&a+c>b)
    System.out.println("YES");
    else
    System.out.println("NO");
    }
    }
    }

    以上两个都可以,但第二个代码和复杂度都要比第一个的小;特别注意输入要用双精度的数值;

     
  • 相关阅读:
    学习git之路--1
    No input file specified. phpStudy nginx报错解决方案
    nginx隐藏tp路由index.php
    tp5命令行
    生成器
    php 解密小程序获取unionid
    根据GUID获取实例
    用SQL将数字转换为中文数字
    TFS无法确定工作区解决方案
    利用SQL语句产生分组序号
  • 原文地址:https://www.cnblogs.com/1314wamm/p/5312617.html
Copyright © 2011-2022 走看看