文章
47
粉丝
109
获赞
8
访问
29.4k
#include<stdio.h>
#include<math.h>
//1125 求三角形的面积
double z(double x1, double y1,double x2,double y2) {
return sqrt((x1-x2)*(x1-x2) + (y1-y2) * (y1-y2));
}//三角形的边长
int main() {
double x1, x2, x3, y1, y2, y3;
while(scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3)!=EOF) {
double a = z(x1,y1,x2,y2);
double b = z(x1,y1,x3,y3);
double c = z(x2,y2,x3,y3);
double p = (a + b + c) / 2;
double sum = sqrt(p * (p - a) * (p - b) * (p - c));
printf("%.2lf\n", sum);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发