编写程序:通过键盘输入三角形的三个边长求三角形的面积。函数的定义部分已经给出请完善程序。函数的定义如下:float areafloat afloat bfloat c float hs; h=05a+b+c; s=sqrthh-ah-bh-c;return s;1函数的调用
#include <stdio.h> #include <math.h>
float area(float a, float b, float c) { float h, s; h = 0.5 * (a + b + c); s = sqrt(h * (h - a) * (h - b) * (h - c)); return s; }
int main() { float x, y, z; printf("请输入三角形的三个边长:"); scanf("%f %f %f", &x, &y, &z); float result = area(x, y, z); printf("三角形的面积为:%f\n", result); return 0; }
原文地址: https://www.cveoy.top/t/topic/jgJE 著作权归作者所有。请勿转载和采集!