本帖最后由 rt3 于 2021-4-24 19:47 编辑 #include <stdio.h>
#include <ctype.h>
#include <math.h>
int main(){
double a=0, b=0, c=0, S=0, h=0;
int FLAG = 0;
printf("请输入三条边:");
scanf("%lf %lf %lf", &a, &b, &c);
printf("a==%lf,b==%lf,c==%lf\n",a,b,c);
if (a+b>c && a+c>b && b+c>a)//是否是三角
{
h = (a + b + c) / 2.0;
S = sqrt(h*(h - a) * (h - b) * (h - c));
printf("面积为 : %.2f\n", S);
if((a==b)&&(b==c)){
FLAG = 2; //是否是等边
}else if(a == b || a == c || c == b){
FLAG = 1;//是否是等腰
}else FLAG = 3;//是一般三角形
}
switch (FLAG)
{
case 1:
printf("%.21f,%.21f,%.21f是等腰三角形。\n", a, b, c);break;
case 2:
printf("%.21f,%.21f,%.21f是等边三角形。\n", a, b, c);break;
case 3:
printf("%.21f,%.2f,%.21f是一般三角形。\n", a, b, c);break;
case 0:
printf("%.21f,%.2f,%.21f不是三角形。\n", a, b, c); break;
default:
printf("未知错误。\n", a, b, c);
}
return 0;
}
|