HDU 2039 三角形

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

java code

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        while (n != 0) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            boolean isSan = false;
            if (a + b > c && a + c > b && b + c > a) {
                isSan = true;
            }
            if (isSan) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
            n--;
        }
        scanner.close();
    }
}```
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容