您的位置:首页 > 编程语言 > C语言/C++

求三角形面积 (sdut oj)

2017-01-27 20:25 337 查看




求三角形面积

Time Limit: 1000MS Memory Limit: 65536KB


Problem Description

已知三角形的边长a、b和c,求其面积。




Input

输入三边a、b、c。




Output

输出面积,保留3位小数。




Example Input

1 2 2.5





Example Output

0.950



Hint

 


Author



参考代码

#include<stdio.h>
#include<math.h>
double f(double a,double b,double c)
{
double s;
double p;
p = (a + b + c) / 2;
s = sqrt(p * (p - a) * (p - b) * (p - c));
return s;
}
int main()
{
double a,b,c;
double s;
scanf("%lf%lf%lf",&a,&b,&c);
s = f(a,b,c);
printf("%.3lf",s);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  函数 c语言 SDUT OJ