C语言三角形面积计算:代码示例及解析
#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/chiC 著作权归作者所有。请勿转载和采集!