import java.util.Arrays;
import java.util.Scanner;
public class Triangle {
int a,b,c;//三角形三边
int arr []=new int [3];
public void infor() {
Scanner input = new Scanner(System.in);
System.out.println("请输入三角形的三条边");
for(int i=0;i<arr.length;i++){
System.out.println("请输入三角形的第"+(i+1)+"条边");
arr[i]=input.nextInt();
}
Arrays.sort(arr);
a=arr[2];
b=arr[1];
c=arr[0];
if(b+c>a) //三角形
triangletype();
else
System.out.println("不构成三角形");
}
public void triangletype()
{
if(b*b+c*c==a*a) { //直角三角形
if (b == c)
System.out.println("等腰直角三角形");
else
System.out.println("直角三角形");
}
if(b*b+c*c<a*a) {//钝角三角形
if (b == c)
System.out.println("等腰钝角三角形");
else
System.out.println("钝角三角形");
}
if(b*b+c*c>a*a) {//锐角三角形
if(c==a)
System.out.println("等边三角形");
else if(b==a||b==c)
System.out.println("等腰三角形");
else
System.out.println("锐角三角形");
}
}
}
测试: