1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 21:58:41 +00:00
202401-programming-assignments/【实践课外】2.选择结构1/7-6 三角形判断.c

25 lines
696 B
C
Raw Normal View History

2024-10-18 10:46:44 +00:00
#include <math.h>
#include <stdio.h>
int main() {
double x1, y1, x2, y2, x3, y3;
scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
double len1 = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
double len2 = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
double len3 = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
if (len1 + len2 <= len3 || len1 + len3 <= len2 || len2 + len3 <= len1) {
printf("Impossible\n");
} else {
double l = len1 + len2 + len3;
double p = l / 2;
double s = sqrt(p * (p - len1) * (p - len2) * (p - len3));
printf("L = %.2lf, A = %.2lf\n", l, s);
}
return 0;
}