题目链接
java代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int a=0,b=0,c=0;
Scanner scanner=new Scanner(System.in);
try{
a=Integer.parseInt(scanner.next());
b=Integer.parseInt(scanner.next());
c=Integer.parseInt(scanner.next());
if(a<=0||a>10000||b<=0||b>10000||c<=0||c>10000){
System.out.println("您输入的数据超出范围限制了!");
return;
}
if(a==b&&a==c){
System.out.printf("equilateral triangle!");
return ;
}
if(a==c||b==c||a==b){
System.out.printf("isosceles triangle!");
return ;
}
if((a+b>c)&&(c+b>a)&&(a+c>b)){
System.out.printf("regular triangle!");
return ;
}
System.out.printf("not a triangle!");
}
catch(Exception ex){
System.out.println("您输入了非整数!");
}
}
}
这里提一下用异常判断输入的是否为整数:百度知道
try{
int num = Integer.parseInt("这里用String");
}catch(Exception ex){
System.out.println("不是int类型");
return ;
}