从键盘上输入三个点的坐标值(1,1)、(2,4)、(3,2),编程求该三角形的面积。
#include<stdio.h>
#include<math.h>
void main()
{
int x1,y1,x2,y2,x3,y3;
float s,t,a,b,c;
printf("输入三个坐标:");
scanf("%d,%d %d,%d %d,%d",&x1,&y1,&x2,&y2,&x3,&y3);
a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
t=(a+b+c)/2;
s=sqrt(t*(t-a)*(t-b)*(t-c));
printf("面积=%f/n",s);
}