首先你已經(jīng)很清楚的說明了你這個(gè)程序是用C語言寫二次函數(shù)的,而當(dāng)a=0時(shí),就不是二次函數(shù)了,應(yīng)該按照一次函數(shù)來進(jìn)行計(jì)算,否則 一個(gè)數(shù)除以0就沒有意義了.~
創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、青秀網(wǎng)絡(luò)推廣、成都微信小程序、青秀網(wǎng)絡(luò)營銷、青秀企業(yè)策劃、青秀品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供青秀建站搭建服務(wù),24小時(shí)服務(wù)熱線:028-86922220,官方網(wǎng)址:chinadenli.net
#include stdio.h
#include stdlib.h
#include math.h
int main()
{
float a,b,c;
float x1,x2,m;
printf("input number a=:");
scanf("%f",a);
printf("input number b=:");
scanf("%f",b);
printf("input number c=:");
scanf("%f",c);
if(a==0)
printf("一根:%f\n",c*(-1)/b);
else if(a==0b==0)
printf("無意義!");
else
{
m=b*b-4*a*c;
if(m0)
{
printf("兩根\n");
printf("x1=%f\n",(-b+sqrt(m))/(2*a));
printf("x2=%f\n",(-b-sqrt(m))/(2*a));
}
else if(m==0)
printf("x1=x2=%f\n",x1);
}
else
printf("無實(shí)根\n");
}
return 0;
}
這個(gè)簡單啊
#includestdio.h
#includemath.h
main()
{
double a,b,c,w;
printf("請輸入三個(gè)數(shù)(方程的系數(shù)),中間用空格分開\n");
scanf("%lf%lf%lf",a,b,c);
w=b*b-4*a*c;
if (w0)printf("方程無解\n");
else if(w==0)printf("方程有一個(gè)解:x=%lf\n",-b/(2*a));
else printf("方程有兩個(gè)解:x1=%lf,x2=%lf\n",(-b+sqrt(w))/(2*a),(-b-sqrt(w))/(2*a));
}
#include stdio.h
#include stdlib.h
#include math.h
int main()
{
float a,b,c;
float x1,x2,m;
printf("input number a=:");
scanf("%f",a);
printf("input number b=:");
scanf("%f",b);
printf("input number c=:");
scanf("%f",c);
m=b*b-4*a*c;
if(m=0a!=0){
if(m0){
x1=(-b+sqrt(m))/(2*a);
x2=(-b-sqrt(m))/(2*a);
printf("兩根\n");
printf("x1=%f\n",x1);
printf("x2=%f\n",x2);}
else
printf("一根\n");
printf("x1=x2=%f\n",x1);}
else
{
if(a=0 b!=0) printf("根是x=-c/b");
if(a=0b=0) printf("為常函數(shù)");
if(a!=0) printf("無根\n");
}
system("PAUSE");
return 0; }
#include stdio.h
#include stdlib.h
#include math.h
int main()
{
float a,b,c,l,t,x1,x2;
printf("input three numbers\n");
scanf("%f%f%f",a,b,c);
t=b*b-4*a*c;
if(t0)
{
x1=(-b+sqrt(t))/(2*a);
x2=(-b-sqrt(t))/(2*a);
printf("%f\n%f\n",x1,x2);
}
else if(t==0)
{
x1=-(b/(2*a));
printf("%f\n%f\n",x1,x1);
}
else
{
l=sqrt(-t)/2/a;
t=-b/2/a;
printf("%f%+fi\n%f%+fi",t,l,t,-l);
}
return 0;
}
當(dāng)前名稱:c語言輸入二次函數(shù) c語言如何輸入兩次
URL地址:http://chinadenli.net/article4/dodddoe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、微信小程序、外貿(mào)建站、手機(jī)網(wǎng)站建設(shè)、定制開發(fā)、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)