首页 > 代码库 > 三角形的两边长大雨另一边

三角形的两边长大雨另一边

import java.util.Scanner;public class Triangle {    public static void main(String[] args){        double d;        System.out.println("请输入三角形的三条边的长度!");        Scanner input = new Scanner(System.in);        double a = input.nextDouble();        double b = input.nextDouble();        double c = input.nextDouble();        if(a <= b){            d = a;            a = b;            b = d;            if(a <= c){                d = a;                a = c;                c = d;            }        }        if(a >= b + c){            System.out.println("Can edges " + a + "," + b + " and " + c + " form a triangle? false");        }        else{            System.out.println("Can edges " + a + "," + b + " and " + c + " form a triangle? ture");        }    }}

读取三角形的三条边,并确定输入是否有效。如果另外两边和大于另一边则输入有效。