#include <stdio.h>
#define swap(x,y){x=x+y;y=x-y;x=x-y;}
/*下面三个函数都是:是返回1,不是返回0*/
int right_triangle(double a,double b,double c); /*判断直角三角形*/
int acute_triangle(double a,double b,double c); /*判断锐角三角形*/
int obtuse_triangle(double a,double b,double c); /*判断钝角三角形*/
int main()
{
double a,b,c; /*三角形的三边*/
scanf("%lf %lf %lf",&a,&b,&c); /*输入三边*/
/*将三边按照从小到大排好*/
if(a>b)
swap(a,b);
if(a>c)
swap(a,c);
if(b>c)
swap(b,c);
/*根据if判断选择三角形*/
if(acute_triangle(a,b,c))
printf("锐角三角形\n");
else if(right_triangle(a,b,c))
printf("直角三角形\n");
else if(obtuse_triangle(a,b,c))
printf("钝角三角形\n");
return 0;
}
int acute_triangle(double a,double b,double c)
{
return(a*a+b*b>c*c);
}
int right_triangle(double a,double b,double c)
{
return(a*a+b*b==c*c);
}
int obtuse_triangle(double a,double b,double c)
{
return(a*a+b*b<c*c);
}
第十一周-判断三角形
最新推荐文章于 2016-12-06 11:18:33 发布