2024-04-25 01:36:11
#include "stdio.h"
#include "math.h"
int main(int argc,char *argv[]){
double a,b,c,C,pi=3.1415926,e=1E-6;
printf("Please enter a, b(Length), C(Angle)...\n");
scanf("%lf%lf%lf",&a,&b,&C);
C=C/180*pi;//angle-->radian
printf("The area of this triangle is %f\n",a/2*b*sin(C));
c=sqrt(a*a+b*b-2*a*b*cos(C));
if(fabs(a-b)<e && fabs(b-c)<e)
printf("It is an equilateral triangle.\n");
else if(fabs(a-b)<e || fabs(b-c)<e || fabs(a-c)<e)
printf("It is an isosceles triangle.\n");
else if(fabs(a*a+b*b-c*c)<e || fabs(a*a+c*c-b*b)<e || fabs(c*c+b*b-a*a)<e)
printf("It is a right triangle.\n");
else
printf("It is a common triangle.\n");
return 0;
}
运行样例:
2024-04-25 04:58:45