习题3-5 三角形判断 (15point(s)).c

在这里插入图片描述
Helen’s formula is used:
在这里插入图片描述
The distance formula between two points is used:
在这里插入图片描述
The code is as follows:

//   Date:2020/3/17
//   Author:xiezhg5
#include <stdio.h>
#include <math.h>
int main(void)
{
	double x1,y1,x2,y2,x3,y3;
    double a,b,c,p;
	scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
	a=(double)(sqrt(pow(fabs(x1-x2),2)+pow(fabs(y1-y2),2)));     //边长a 
	b=(double)(sqrt(pow(fabs(x1-x3),2)+pow(fabs(y1-y3),2)));    //边长b 
	c=(double)(sqrt(pow(fabs(x2-x3),2)+pow(fabs(y2-y3),2)));   //边长c 
	p=(a+b+c)/2.0;
	if((a+b)<=c||(a+c)<=b||(b+c)<=a)
	{
		printf("Impossible\n");
	}
	else
	{
		printf("L = %.2lf, A = %.2lf\n",a+b+c,sqrt(p*(p-a)*(p-b)*(p-c)));  //运用了海伦公式 
	}
	return 0;
}
发布了65 篇原创文章 · 获赞 28 · 访问量 1743

猜你喜欢

转载自blog.csdn.net/qq_45645641/article/details/104931000
今日推荐