题目链接
题意:
给出三条线段 a,b,c的长度,均是不大于 10000 的整数。打算把这三条线段拼成一个三角形,它可以是什么三角形
思路:
当两短边的平方和大于一长边的平方,说明是锐角三角形。
当两短边的平方和等于一长边的平方,说明是直角三角形。
当两短边的平方和小于一长边的平方,说明是钝角三角形。
我们只需要用尽可能简洁明了的代码完成上述判断即可。
代码:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=1e6+7;
const int mod=1e9+7;
const int inf=0x7fffffff;
const double pi=3.1415926535;
signed main()
{
int d[4];
cin>>d[1]>>d[2]>>d[3];
sort(d+1,d+4);
if(d[1]+d[2]<=d[3])
{
cout<<"Not triangle"<<endl;
}
if(d[1]*d[1]+d[2]*d[2]==d[3]*d[3])
{
cout<<"Right triangle"<<endl;
}
else if(d[1]*d[1]+d[2]*d[2]>d[3]*d[3])
{
cout<<"Acute triangle"<<endl;
}
else if(d[1]*d[1]+d[2]*d[2]< d[3]*d[3])
{
cout<<"Obtuse triangle"<<endl;
}
if(a==b||b==c||a==c)
{
cout<<"Isosceles triangle"<<endl;
}
if(a==b&&b==c)
{
cout<<"Equilateral triangle"<<endl;
}
return 0;
}