题解 | #计算三角形的周长和面积#
计算三角形的周长和面积
https://www.nowcoder.com/practice/109a44d649a142d483314e8a57e2c710
#include <stdio.h>
#include <math.h>
int main() {
float a = 0;
float b = 0;
float c = 0;
scanf("%f %f %f", &a, &b, &c);
float p = (a + b + c) / 2;
// 本题主要运用海伦公式求得三角形的面积
// 公式:S = sqrt(p(p-a)(p-b)(p-c))
printf("circumference=%.2f area=%.2f", a + b + c, sqrt(p * (p - a) * (p - b) * (p - c)));
return 0;
}
腾讯公司福利 1143人发布