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

int main() {
    double a, b, c;
    printf("请输入三角形的三条边的边长:\n");
    scanf("%lf %lf %lf", &a, &b, &c);

    if (a > 0 && b > 0 && c > 0 && (a + b > c) && (a + c > b) && (b + c > a)) {
        double p = (a + b + c) / 2;  // 计算三角形的半周长
        double s = sqrt(p * (p - a) * (p - b) * (p - c));  // 计算三角形的面积
        printf("三角形的面积为:%lf\n", s);
    } else {
        printf("输入的边长不合法,无法构成三角形。\n");
    }

    return 0;
}

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

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