题解 | #三角形判断#

三角形判断

https://www.nowcoder.com/practice/689ec1e742394e09b1059556fc167b65

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            T t = new T();
            t.info(a,b,c);
        }
    }
}

class T{
    public void info(int a,int b,int c){
        int max =(a>b?a:b)>c?(a>b?a:b):c;
        if(a+b+c>2*max){
            //两边之和>第三边
            if(a==b&&b==c){
                System.out.println("Equilateral triangle!");
            }else if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a)){
                System.out.println("Isosceles triangle!");
            }else{
                System.out.println("Ordinary triangle!");
            }
        }else{
            System.out.println("Not a triangle!");
        }
    }
}

全部评论

相关推荐

头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-01 11:47
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务