#include <stdio.h> #include <math.h>

// 声明函数 float zhouchang(float a, float b, float c); float mianji(float a, float b, float c);

int main() { float a, b, c; printf('请输入三角形的三边长:\n'); scanf('%f %f %f', &a, &b, &c);

float perimeter = zhouchang(a, b, c); float area = mianji(a, b, c);

printf('三角形的周长为:%.2f\n', perimeter); printf('三角形的面积为:%.2f\n', area);

return 0; }

// 定义函数:求周长 float zhouchang(float a, float b, float c) { return a + b + c; }

// 定义函数:求面积 float mianji(float a, float b, float c) { float s = (a + b + c) / 2; // 计算半周长 return sqrt(s * (s - a) * (s - b) * (s - c)); // 使用海伦公式计算面积 }


原文地址: https://www.cveoy.top/t/topic/o0Ai 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录