第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

本人學(xué)生,oj平臺(tái)一道題一直通不過敢問哪里出錯(cuò)。

本人學(xué)生,oj平臺(tái)一道題一直通不過敢問哪里出錯(cuò)。

C
慕虎8333395 2017-10-27 23:44:53
#include<stdio.h>#include<math.h>int main(){ float a,b,c,d,f1,f2,y,p,m; scanf("%f %f %f",&a,&b,&c); d=b*b-4*a*c; y=sqrt(d); f1=(-b+y)/(2*a); f2=(-b-y)/(2*a); if(a==0) { printf("The equation is not quadratic."); } else if(a!=0) { if(d==0) { printf("The eaquation has two equal roots: %.4f.",f1);? } else if(d>0) { y=sqrt(d); printf("The eaquation has two distinct real roots: %.4f and %.4f.",f1,f2); } else if(d<0) { m=sqrt(-d)/(2*a); p=-b/(2*a); printf("The eaquation has two complex roots: %.4f+%.4fi and %.4f-%.4fi.",p,m,p,m); } } return 0;?}?
查看完整描述

2 回答

?
慕沐8454250

TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超0個(gè)贊

#include<stdio.h>

#include<math.h>

int main()

{

float a, b, c, d, f1, f2, y;

scanf_s("%f %f %f", &a,&b,&c);

d = b*b - 4 * a*c;

y = (float)sqrt(d);

if (a == 0)

{

printf("The equation is not quadratic.");

}

else if (a != 0)

{

f1 = (-b + y) / (2 * a);

f2 = (-b - y) / (2 * a);

if (d == 0)

{

printf("The eaquation has two equal roots: %.4f.", f1);

}

else if (d>0)

{

printf("The eaquation has two distinct real roots: %.4f and %.4f.", f1, f2);

}

else if (d<0)

{

printf("The eaquation has two complex roots: %.4f and %.4f",f1,f2);

}

}

system("pause");

return 0;

}


查看完整回答
反對(duì) 回復(fù) 2017-10-28
?
慕虎8333395

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊

求ax2+bx+c=0的根。分別考慮d=b2-4ac大于零,等于零和小于零三種情況。

a、b、c要求是浮點(diǎn)型。程序要對(duì)a、b、c的各種情況進(jìn)行處理。如判斷a是否為0,b2-4ac分別為大于0、小于0、等于0。

解答提示:

1)求一浮點(diǎn)數(shù)的平方根可以用庫函數(shù)sqrt(x)。x要求是浮點(diǎn)數(shù)。如以下賦值語句:y=sqrt(x);表示求x的平方根,賦值給y。為了使用該函數(shù),需要在main函數(shù)之前加上預(yù)處理語句:#include<math.h>。

2)如何判斷兩個(gè)浮點(diǎn)數(shù)是否相等:

假設(shè)f1和f2是兩個(gè)浮點(diǎn)數(shù)。若想寫一個(gè)關(guān)系表達(dá)式,判斷f1和f2是否相等,不能寫成:if(f1==f2),而是要寫成f1和f2的差的絕對(duì)值近似接近于0,如寫成:if(fabs(f1-f2)<=1e-6)。其中1e-6表示10的-6次方,fabs函數(shù)用于求絕對(duì)值。原因:浮點(diǎn)數(shù)在內(nèi)存中是以近似值存儲(chǔ)的,所以不能執(zhí)行是否相等的比較。

輸入格式


輸入3個(gè)浮點(diǎn)數(shù),代表a,b,c。

輸出格式


輸出對(duì)應(yīng)方程的根:

當(dāng)該方程非一元二次方程時(shí),輸出“The equation is not quadratic.”。

當(dāng)該一元二次方程有兩個(gè)相等的實(shí)數(shù)根時(shí),輸出“The equation has two equal roots: x.”。

當(dāng)該一元二次方程有兩個(gè)不相等的實(shí)數(shù)根時(shí),輸出“The equation has two distinct real roots: x1 and x2.”。(x1 ?>?x2)

當(dāng)該一元二次方程有兩個(gè)不相等的虛數(shù)根時(shí),輸出“The equation has two complex roots: x1 and x2.”。

?

若x為虛數(shù),則x1的格式為a+bi,x2的格式為a-bi.(其中a,b保留4位有效數(shù)字, 例如:3.0000+3.0000i)

所有的數(shù)均保留4位有效數(shù)字。


查看完整回答
反對(duì) 回復(fù) 2017-10-28
?
慕虎8333395

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊

http://img1.sycdn.imooc.com//59f3548a0001b94809410611.jpg這是題目

查看完整回答
反對(duì) 回復(fù) 2017-10-27
  • 2 回答
  • 1 關(guān)注
  • 2352 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)