知道三角形三个顶点坐标,求面积,我觉得我的没错,但未通过,麻烦大佬帮忙看下
#include<stdio.h>#include<math.h>
double dist(double x1,double y1,double x2,double y2);//求边长
int main()
{
int x1,y1,x2,y2,x3,y3;
scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
double a=dist(x1,y1,x2,y2);
double b=dist(x2,y2,x3,y3);
double c=dist(x1,y1,x3,y3);
double s=(a+b+c)/2;
double S=sqrt(s*(s-a)*(s-b)*(s-c));
printf("%.2lf",S);
return 0;
}
double dist(double x1,double y1,double x2,double y2)
{
double dist = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
return dist;
}