c语言编程练习题:7-70 输出三角形面积和周长
作者:yunjinqi   类别:    日期:2023-05-30 15:22:15    阅读:117 次   消耗积分:0 分    

image.png

#include <stdio.h>
#include <math.h>
int main(){
    int a,b,c;
    double area=0,perimeter=0;
    double s;
    if (scanf("%d",&a)!=EOF && scanf("%d",&b)!=EOF && scanf("%d",&c)!=EOF && (a+b)>c && (a+c)>b && (b+c)>a){
        // 计算最大的5分钱个数
        s = (a+b+c)/2.0;
        area = sqrt(s*(s-a)*(s-b)*(s-c));
        perimeter = a+b+c;
        printf("area = %.2f; perimeter = %.2f",area,perimeter);
    }else{
        printf("These sides do not correspond to a valid triangle");
    }
    return 0;
}


版权所有,转载本站文章请注明出处:云子量化, http://www.woniunote.com/article/195
上一篇:c语言编程练习题:7-69 换硬币
下一篇:c语言编程练习题:7-71 求平方与倒数序列的部分和