已知三点,求三点组成的三角形面积的程序
1个回答

#include

#include

void main()

{

float x1,y1,x2,y2,x3,y3;

float a,b,c,n;

float s;

printf("Please enter the point");

scanf("%f",&x1);

scanf("%f",&y1);

scanf("%f",&x2);

scanf("%f",&y2);

scanf("%f",&x3);

scanf("%f",&y3);

a = sqrt((x2-x1)^2+(y2-y1)^2);

b = sqrt((x3-x1)^2+(y3-y1)^2);

c = sqrt((x3-x2)^2+(y3-y2)^2);

n = (a+b+c)/2;

s = sqrt(n*(n-a)*(n-b)*(n-c));

printf("%.2fn",&s);

}

假如公式没记错的话,这个应该没有问题~