三角形的判定

来源:互联网 发布:c语言头文件下载 编辑:程序博客网 时间:2024/04/29 15:40
package wei;import java.util.Scanner; //通过import语句引入java.util.Scanner包public class dhf {    public static void main(String[] args) {        // TODO 自动生成的方法存根        int a,b,c;//三边的定义        System.out.println("请输入三角形的三条边:");        Scanner sc=new Scanner(System.in);//Scanner包的实例化        System.out.print("a=");//三边的输出        a=sc.nextInt();        System.out.print("b=");        b=sc.nextInt();        System.out.print("c=");        c=sc.nextInt();        if((a+b)>c&&(a+c)>b&&(b+c)>a) //判断条件:任意两边之和大于第三边则组成三角形            System.out.println(a+","+b+","+c+"能构成三角形");        else            System.out.println(a+","+b+","+c+"不能构成三角形");    }}

这里写图片描述

知识点:
算术运算符;
逻辑运算符;
比较运算符;
条件运算符;
表达式;
运算符的优先级。

我的心得:JAVA和数学息息相关,逻辑之间要理解明白。

原创粉丝点击