海伦公式

海伦公式

已知三角形三边长度a,b,c,求三角形的面积 S

(p=\frac{a+b+c}{2})

S=$\sqrt{p(p-a)p-b)(p-c)}$

以上在高中是不是算的头昏眼花? 现在可以雇佣计算机帮你算!

以下是代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
#include <math.h>
int main(){
float a,b,c,p;
double area;
printf("Enter 3 floats:");
scanf("%f,%f,%f",&a,&b,&c);
p=(a+b+c)/2.0;
area=p*(p-a)*(p-b)*(p-c);
area=sqrt(area);
printf("area=%.2f\n",area);
return 0;
}

海伦公式
http://example.com/2025/10/27/海伦公式/
作者
王柏森
发布于
2025年10月27日
许可协议