[cpp] view plain copy
-
#include<iostream.h>
#include<math.h>
void main()
{
int a,b,c;
double s,area;
cout<<"输入三角形的3边:";
cin>>a>>b>>c;
s=1/2*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c));
cout<<"三角形的面积"<<area;
}
- 运行结果:
[cpp] view plain copy
#include<iostream.h>
#include<math.h>
void main()
{
int a,b,c;
double s,area;
cout<<"输入三角形的3边:";
cin>>a>>b>>c;
s=1/2*(a+b+c);
area=sqrt(s*(s-a)*(s-b)*(s-c));
cout<<"三角形的面积"<<area;
}