Input from the keyboard of the coordinate values of three points (1,1), (2,4), (3,2), programmed find the area of the triangle.

#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);
}

 

Guess you like

Origin www.cnblogs.com/bobotongxue/p/12290658.html