作者:yunjinqi 类别:
日期:2023-05-30 15:50:21
阅读:124 次 消耗积分:0 分
#include <stdio.h>
#include <math.h>
int main(){
double x1,y1,x2,y2,x3,y3;
double a,b,c;
double area=0,perimeter=0;
double s;
if (scanf("%lf",&x1)!=EOF && scanf("%lf",&y1)!=EOF && scanf("%lf",&x2)!=EOF &&
scanf("%lf",&y2)!=EOF && scanf("%lf",&x3)!=EOF && scanf("%lf",&y3)!=EOF){
a = sqrt(1.0*(x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
b = sqrt(1.0*(x3-x1)*(x3-x1) + (y3-y1)*(y3-y1));
c = sqrt(1.0*(x2-x3)*(x2-x3) + (y2-y3)*(y2-y3));
if ((a+b)>c && (a+c)>b && (b+c)>a){
s = (a+b+c)/2.0;
area = sqrt(s*(s-a)*(s-b)*(s-c));
perimeter = a+b+c;
printf("L = %.2f, A = %.2f",perimeter,area);
}else{
printf("Impossible");
}
}else{
printf("These sides do not correspond to a valid triangle");
}
return 0;
}