求三角形面积
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 S(double a,double b,double c)
{
double p,s;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
return s;
}
int main()
{
double a,b,c,s;
scanf("%lf %lf %lf",&a,&b,&c);
s=S(a,b,c);
printf("%.3lf",s);
return 0;
}
#include<math.h>
double S(double a,double b,double c)
{
double p,s;
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
return s;
}
int main()
{
double a,b,c,s;
scanf("%lf %lf %lf",&a,&b,&c);
s=S(a,b,c);
printf("%.3lf",s);
return 0;
}