input output 格式自己修改~
发一个无聊版的看看(未经过严格测试,可能有错漏)
#include<stdio.h>
#include<math.h>
double fun_length(double x1,double y1,double x2,double y2)
{
return (sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}
double fun_area(double l,double l1,double l2,double l3)
{
return (sqrt(l*(l-l1)*(l-l2)*(l-l3)));
}
int main()
{
double x1,y1,x2,y2,x3,y3;
double l,l1,l2,l3;
double s;
scanf("%lf,%lf%lf,%lf%lf,%lf",&x1,&y1,&x2,&y2,&x3,&y3);
l1=fun_length(x1,y1,x2,y2);
l2=fun_length(x2,y2,x3,y3);
l3=fun_length(x3,y3,x1,y1);
l=(l1+l2+l3)/2;
s=fun_area(l,l1,l2,l3);
if (s!=0)
printf("面积为:%f\n",s);
else printf("not a triangle\n");
return 0;
}