判断是否是三角形且其类型

img

把输出改成中文即可。


#include<iostream>
using namespace std;
int main(){
    double a,b,c;
    cout<<"Please enter the length of A, B and C:";
    cin>>a>>b>>c;
    if(a>c){double t=0;t=a;c=a;a=c;} 
    else if(b>c){double t=b;b=c;c=t;};
    if(a+b>c)
    {if(a==b==c)cout<<"This is an equilateral triangle.";//等边三角形
    else  if(a==b)cout<<"This is an isosceles triangle.";//等腰三角形
     else if(a*a+b*b==c*c&&a==b)cout<<"This is an isosceles right triangle.";//等腰直角三角形 
      else
    if(a*a+b*b>c*c)cout<<"This is an acute triangle.";//锐角三角形 
    else if(a*a+b*b==c*c)cout<<"This is a right triangle.";//直角三角形 
            else cout<<"This is an obtuse triangle.";//钝角三角形 
    }
    else cout<<"this is not a trangle";
    
    return 0;
}