运用多重判断
#include<iostream> using namespace std; int main() { int a,b,c; cout<<"please input a,b and c : "<<endl; cin>>a>>b>>c; if((a+b<c)||(a+c<b)||(b+c<a)||(a-b>=c)||(a-c>=b)||(b-c>=a)||(b-a>=c)||(c-a>=b)||(c-b>=a))//注意不要忘了有等于的情况 { cout<<"can not be a triangle."<<endl; }else if((a*a==b*b+c*c)||(b*b==a*a+c*c)||(c*c==a*a+b*b)) { cout<<"it is a right triangle(直角三角形)."<<endl; }else if(a==b&&b==c)//注意不能写成a==b==c { cout<<"it is an equilateral triangle(等边三角形)."<<endl; } return 0; }