
#include<stdio.h>
#include<math.h>
int triangle(int x1,int x2,int x3,int y1,int y2,int y3){
float a,b,c,area=0,s=0;
a = sqrt( pow( abs(x1-x2) ,2) + pow( abs(y1-y2) ,2) ) ;//利用公式分别求三边长度
b = sqrt( pow( abs(x1-x3) ,2) + pow( abs(y1-y3) ,2) ) ;
c = sqrt( pow( abs(x2-x3) ,2) + pow( abs(y2-y3) ,2) ) ;
area = sqrt(s*(s-a)*(s-b)*(s-c));
return area;
}
int main()
{
int x1,x2,xx3,y1,y2,y3;
float area = 0;
printf("请输入三个坐标:\n");
scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&y1,&y2,&y3);
area = triangle(x1,x2,x3,y1,y2,y3);
printf("面积为:%.2f\n",area);
return 0;
}
#include <math.h>
#include <stdio.h>
double area(double x,double y,double z){
double p=(x+y+z)/2;
return sqrt(p*(p-x)*(p-y)*(p-z));
}
int main(){
double x1,y1,x2,y2,x3,y3,a,b,c;
printf("please enter the location of the three pointers");
scanf ("%lf%lf %lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
a=sqrt(pow(abs(x1-x2),2)+pow(abs(y1-y2),2));
b=sqrt(pow(abs(x1-x3),2)+pow(abs(y1-y3),2));
c=sqrt(pow(abs(x3-x2),2)+pow(abs(y3-y2),2));
printf("%lf",area(a,b,c));
}