本文共 583 字,大约阅读时间需要 1 分钟。
三角形成立的充要条件:任意两边长之和大于第三边边长
三角形面积公式:(1)1/2*底边*边长 1/2*a*h
(2) 1/2两边之积乘夹角的正弦值 1/2*a*b*sinc
(3) 海伦公式 p=1/2(a+b+c) A=sqrt(p*(p-a)*(p-b)*(p-c))
c语言代码:
#include <stdio.h>
#include <stdlib.h> #include <math.h> int main() { double x1,y1,x2,y2,x3,y3; double a,b,c,L,A,p; scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3); a=sqrt(pow(x1-x2,2)+pow(y1-y2,2)); b=sqrt(pow(x3-x2,2)+pow(y3-y2,2)); c=sqrt(pow(x1-x3,2)+pow(y1-y3,2)); if(a+b<=c || a+c<=b || b+c<=a) { printf("Impossible"); exit(0); } L=a+b+c; p=L/2.0; A=sqrt(p*(p-a)*(p-b)*(p-c)); printf("L = %.2f, A = %.2f\n",L,A); return 0; }转载地址:http://hwqof.baihongyu.com/