求五边形面积,不知道这个程序哪错了?
#include<iostream.h>#include<math.h>
int chang(int a,int b,int c,int d)
{
double l;
l=sqrt((a-c)*(a-c)+(b-d)*(b-d));
return l;
}
int hailun(double a,double b,double c)
{
double s,y;
y=(a+b+c)/2;
s=sqrt(y*(y-a)*(y-b)*(y-c));
return s;
}
void main()
{
int q,w,r,t,u,i,p,a,d,f;
double h;
cout<<"请输入第一个点坐标:";
cin>>q>>w;
cout<<"请输入第二个点坐标:";
cin>>r>>t;
cout<<"请输入第三个点坐标:";
cin>>u>>i;
cout<<"请输入第四个点坐标:";
cin>>p>>a;
cout<<"请输入第五个点坐标:";
cin>>d>>f;
h=hailun(chang(q,w,r,t),chang(q,w,u,i),chang(r,t,u,i))+hailun(chang(q,w,p,a),chang(q,w,u,i),chang(u,i,p,a))+hailun(chang(q,w,p,a),chang(q,w,d,f),chang(p,a,d,f));
cout<<"面积为:"<<h<<endl;
}