#include <bits/stdc++.h>
using namespace std;
int main()
{
/*
#ifndef ONLINE_JUDGE
freopen("test.txt","r",stdin);
freopen("test.out","w",stdout);
#endif
*/
double a,b,c,l,s;
bool flag=true;
while(flag)
{
printf("Please input the triangle's side lengths:\n");
printf("(input three zero with the blank to stop the program.)\n");
scanf("%lf%lf%lf",&a,&b,&c);
if(!(a&&b&&c)) break;
if(a+b>c&&b+c>a&&a+c>b){
l=1.0*(a+b+c)/2;
s=sqrt(l*(l-a)*(l-b)*(l-c)); //"sqrt"included in math.h
if(s-(int)s<1e-5) printf("%d\n",(int)s);
else printf("%.3f\n",s);
}else printf("it's not triangle!\n");
printf("\n");
}
return 0;
}
三角形面积计算
最新推荐文章于 2022-11-22 01:33:52 发布