标签:style blog color java for ar div new
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"); } } }
读取三角形的三条边,并确定输入是否有效。如果另外两边和大于另一边则输入有效。
标签:style blog color java for ar div new
原文地址:http://www.cnblogs.com/Amoxicil/p/3897810.html