#已知三角形的三边,求三角形的面积(不考虑三角形不存在的情况)

结果保留6位小数

例如:

输入:3 4 5

输出:6.000000

代码:#include <stdio.h>

#include <stdlib.h>

#include <math.h>//加入数学函数库,后面要用到sqrt开方


int main()

{

   double a,b,c,C,S;

   scanf("%lf%lf%lf",&a,&b,&c);

   C=(a+b+c)/2;

   S=sqrt(C*(C-a)*(C-b)*(C-c));

   printf("%.6lf",S);

   return 0;

}

c语言训练A6_函数库