2025-03-06 23:47:59 +08:00

25 lines
700 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
功能:功能:输入三角形的三边长,判断能否构成三角形,若能,利用海伦公式计
算该三角形的面积计算结果保留3位小数。
l=(a+b+c)/2s=sqrt(l*(l-a)*(l-b)*(l-c))
--------------------------------------------------------*/
#include <stdio.h>
#include <math.h>
main()
{
float a,b,c,s,l;
scanf("%f,%f,%f",&a , &b , &c);
if(a+b<c||a+c<b||b+c<a)
printf("该3个数据不能构成三角形\n");
else
{
/**********Program**********/
l=(a+b+c)/2;
s=sqrt(l*(l-a)*(l-b)*(l-c));
/********** End **********/
printf("该三角形的面积为%.3f\n",s);
}
}