平面几何问题之三角形的面积
已知三角形的三个顶点,求三角开的面积 这题目以前做过练习,直接复制给你好了#include <stdio.h>
#include <math.h>
double S_tri(double ax, double ay, double bx, double by, double cx, double cy)
{
double S;
S = 0.5 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by));
if (S >= 0)
return S;
else
return (-1.0 * S);
}
void main()
{
double S, ax, ay, bx, by, cx, cy;
scanf("%lf%lf%lf%lf%lf%lf", &ax, &ay, &bx, &by, &cx, &cy);
S = S_tri(ax, ay, bx, by, cx, cy);
printf("S_triangle = %lf\n", S);
} #include <stdio.h>
#include <math.h>
double S_tri(double ax, double ay, double bx, double by, double cx, double cy)
{
double S;
S = 0.5 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by));
if (S >= 0)
return S;
else
return (-1.0 * S);
}
void main()
{
double S, ax, ay, bx, by, cx, cy;
scanf("%lf%lf%lf%lf%lf%lf", &ax, &ay, &bx, &by, &cx, &cy);
S = S_tri(ax, ay, bx, by, cx, cy);
printf("S_triangle = %lf\n", S);
}
页:
[1]