计算三角形面积
/*
功能:计算三角形面积
日期:2013-06-08
*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
double countAreaOfTtriangle (double a,double b,double c);
int main(void)
{
double a,b,c,area;
printf("请输入三角形三条边的边长:");
scanf("%lf%lf%lf",&a,&b,&c);
area = countAreaOfTtriangle(a,b,c);
printf("该三角形的面积为:%.3lf",area);
system("pause");
}
double countAreaOfTtriangle (double a,double b,double c)
{
double Area,s;
if(a+b>c && a+c>b && c+b>a)
{
s = ( a + b + c ) / 2.0 ;
Area = sqrt(s*(s-a)*(s-b)*(s-c));
return Area;
}
else
{
return -1.0;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Preview
除特别注明外,本站所有文章均为 Windcoder网 原创,转载请注明出处来自: calculate-triangle-area
Loading comments...

Preview
No Data