题目描述输入输出案例具体实现
—— C语言—— C++—— Python
题目描述一个三角形的三边长分别是 a,b,c,计算它的面积(最多一位小数)
输入输出案例输出 3 4 5 —— 输出 6.0
具体实现 —— C语言#include—— C++#include int main(void){ double a, b, c, d; scanf("%lf %lf %lf", &a, &b, &c); // 3 4 5 d = (a+b+c)/2; printf("%.1lf", sqrt(d*(d-a)*(d-b)*(d-c))); // 6.0 return 0; }
#include—— Python#include #include using namespace std; int main(){ double a, b, c, d; cin >> a >> b >> c; d = (a+b+c)/2; cout << fixed << setprecision(1) << sqrt(d*(d-a)*(d-b)*(d-c)) << endl; return 0; }
import math a, b, c = input().split() d = (float(a)+float(b)+float(c))/2 e = math.sqrt(d*(d-float(a))*(d-float(b))*(d-float(c))) round(e, 1) # 保留一位小数 print(e)



