精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • C語(yǔ)言:用海倫公式求三角形面積

    C語(yǔ)言:用海倫公式求三角形面積
    我編了如下程序:
    #include
    #define s ((a+b+c)/2)
    void main()
    {
    float a,b,c;
    double area;
    scanf("%f%f%f",&a,&b,&c);
    if(a>=b+c || b>=a+c || c>=a+b)
    printf("error\n");
    else
    {
    area=sqrt((double)(s*(s-a)*(s-b)*(s-c)));
    printf("%f\n",area);
    }
    }
    運(yùn)行后輸入a,b,c的值:2 3 4
    運(yùn)行結(jié)果卻是-32704.000000,請(qǐng)問(wèn)這是什么地方出了問(wèn)題?
    其他人氣:489 ℃時(shí)間:2019-10-19 11:14:18
    優(yōu)質(zhì)解答
    你用到了函數(shù)sqrt,這個(gè)需要有頭文件math.h
    在最上面加上#include 再運(yùn)行就可以了,即為:
    #include
    #include
    #define s ((a+b+c)/2)
    void main()
    {
    float a,b,c;
    double area;
    scanf("%f%f%f",&a,&b,&c);
    if(a>=b+c || b>=a+c || c>=a+b)
    printf("error\n");
    else
    {
    area=sqrt((double)(s*(s-a)*(s-b)*(s-c)));
    printf("%f\n",area);
    }
    }
    我調(diào)試過(guò),可以正常運(yùn)行.
    我來(lái)回答
    類似推薦
    請(qǐng)使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁(yè)提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版