计算三角形面积
include<stdio.h>
include<math.h>
double area(double a,double b,double c)
{
double s,sarea=-1;
if(a+b>c&&b+c>a&&c+a>b)
{
s=(a+b+c)/2;
sarea=sqrt(s(s-a)(s-b)*(s-c));
}
return sarea;
}
void main()
{
double a,b,c,sarea;
printf("请输入三个数:");
scanf("%lf%lf%lf",&a,&b,&c);
sarea=area(a,b,c);
if(sarea>0)
printf("可以构成三角形,其面积为:%.2lf\n",sarea);
else
printf("不可以构成三角形\n");
}
标签:lf%,sarea,area,double,笔记,printf,三角形 From: https://www.cnblogs.com/chengsongbiao/p/17166160.html