//输入边长,判断三角形类型
void numSort(int a[], int count)
{
for (int i = 0; i < count - 1; i++)
{
bool bSort = true;
for (int j = 0; j < count - i - 1; j++)
{
if (a[j] > a[j + 1])
{
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
bSort = false;
}
}
if (bSort)
break;
}
}
string getTriangleType(int a,int b,int c)
{
string type;
//首先排序a,b,c
int length[3] = { a,b,c };
numSort(length, 3);
//判断a,b,c是否能构成三角形a+b>c
a = length[0]; b = length[1]; c = length[2];
if (a+b>c)
{
if (a == b && b == c)
{
return "等边三角形";
}
else if (a == b || a == c || b == c)
{
if (a*a + b * b == c * c)
return "等腰直角三角形";
else
return "等腰三角形";
}
else if (a*a + b * b > c*c)
return "锐角三角形";
else if (a*a + b * b < c*c)
return "钝角三角形";
else if (a*a + b * b == c * c)
return "直角三角形";
}
else
type = "这不是一个三角形";
return type;
}
int main()
{
cout << "please input three numbers:" << endl;
int a, b, c;
cin >> a >> b >> c;
cout<<getTriangleType(a, b, c);
system("pause");
return 0;
}