BUPT-homework/pset2/6-triangle.c
2021-09-29 22:20:05 +08:00

19 lines
395 B
C

#include <math.h>
#include <stdio.h>
int main(void) {
// Initialize values
int a, b, c;
scanf("%i %i %i", &a, &b, &c);
// Calculate S and area's 2 power
double s = (a + b + c) / (double)2;
double area = (s * (s - a) * (s - b) * (s - c));
// Print answer
(area > 0) ? printf("%.3lf", sqrt(area))
: printf("The edges cannot make up of a triangle.");
return 0;
}