输入三个数,表示三角形的三个边,求三角形的面积
输入
数据只有一行,包含三个正实数。测试数据保证是三边可以围成三角形。
输出
三角形的面积。
样例输入
3 4 5
样例输出
6.000000
源代码:
#include <stdio.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
double a,b,c,s,area;
scanf("%lf%lf%lf",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));//三角形面积公式
printf("%f\n",area);
return 0;
}