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

  • <center id="usuqs"></center>
  • 
    
  • 求方程a*x*x+b*x+c的根,用3個函數(shù)分別求當(dāng)判別式大于0,小于0,等于0的根并輸入結(jié)果.從主函數(shù)輸入a,b,c

    求方程a*x*x+b*x+c的根,用3個函數(shù)分別求當(dāng)判別式大于0,小于0,等于0的根并輸入結(jié)果.從主函數(shù)輸入a,b,c
    各位看看我的程序,結(jié)果只到了輸出判別式disc的那步,然后不執(zhí)行子函數(shù),哪里錯了...
    #include
    #include
    int dengyu(int a,int b,int c)
    {
    double x1,x2,p,q,disc;
    p=-b/(2.0*a);
    q=sqrt(disc)/(2.0*a);
    x1=p+q;
    x2=p-q;
    printf("x1=%f\tx2=%f\n",x1,x2);
    getchar();
    return 0;
    }
    int dayu(int a,int b,int c)
    {
    double x1,x2,p,q,disc;
    p=-b/(2.0*a);
    q=sqrt(disc)/(2.0*a);
    x1=p+q;
    x2=p-q;
    printf("x1=%f\tx2=%f\n",x1,x2);
    getchar();
    return 0;
    }
    int xiaoyu(int a,int b,int c)
    {
    double p,q,disc;
    p=-b/(2*a);
    q=sqrt(-disc)/(2*a);
    printf("x1=%f+%fi\tx2=%f-%fi\n",p,q,p,q);
    getchar();
    return 0;
    }
    void main()
    {
    int a,b,c;
    int disc;
    printf("請按順序輸入二元一次方程的二次項系數(shù)a(不為0),一次項系數(shù)b,常數(shù)項c\n");
    scanf("%d%d%d",&a,&b,&c);
    disc=b*b-4*a*c;
    printf("disc=%d",disc);
    if(disc=0)
     dengyu(a,b,c);
    if(disc>0)
     dayu(a,b,c);
    if(disc
    其他人氣:763 ℃時間:2020-10-01 13:41:30
    優(yōu)質(zhì)解答
    if(disc=0)改為if(disc==0)
    disc=0為賦值語句.
    在所有的調(diào)用函數(shù)里出現(xiàn)了disc,但disc沒有計算且沒有初始化,需重新計算吧
    另外建議printf("disc=%d",disc);改為printf("disc=%d\n",disc);進(jìn)行換行,顯示效果會好點(diǎn)
    我來回答
    類似推薦
    請使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版