#include?stdio.h
創(chuàng)新互聯(lián)建站專注服務(wù)器托管服務(wù)十年,提供服務(wù)器租用、虛擬主機、域名注冊、云服務(wù)器、云主機租用、雙線服務(wù)器托管、建站等服務(wù)
#include?math.h
int?main()
{
float?a=5,?b;
b=sqrt(a);
printf("a的平方根為:%f\n",b);
return?0;
}
#include stdio.h
int main(void)
{
double a,b,c,d,e;
double x1,x2;
printf("請輸入ax^2+bx +c = 0中a,b,c的值");
scanf("%lf,%lf,%lf",a,b,c);
e = b * b - 4 * a * c;
if (e0) {
printf("無解,請重新輸入\n");
scanf("%lf,%lf,%lf",a,b,c);
}
printf("輸入正確,正在計算....\n");
d = sqrt(e);
x1 = (-b + d)/(2 * a);
x2 = (-b - d)/(2 * a);
printf("x1=%f\n",x1);
printf("x2=%f\n",x2);
return 0;
}
#includestdio.h
#includestdlib.h
#includemath.h
int main()
{
float a,b,c,x,x1,x2,d;
scanf("%f %f %f",a,b,c);
d=b*b-4*a*c;
if(a==0)
{
if(b==0)
{
if(0==c)
{
printf("等式0!\n");
}
else
{
printf("輸入錯誤!\n");
}
}
else
{
printf("只能構(gòu)成一元一次方程,x=%.6f\n",0==-(float)c/b ? 0 : -(float)c/b);
}
}
else
{
if(d0)
{
x1=(-b+sqrt(-d))/(2.0*a);
x2=(-b-sqrt(-d))/(2.0*a);
printf("x1=%.6f+%.6fi\nx2=%.6f-%.6fi\n",(-b)/(2.0*a),sqrt(-d)/(2.0*a),(-b)/(2.0*a),sqrt(-d)/(2.0*a));
}
else if(d==0)
{
printf("x1=x2=%.6f\n",(-b)/(2.0*a));
}
else
{
x1=(-b+sqrt(d))/(2.0*a);
x2=(-b-sqrt(d))/(2.0*a);
printf("x1=%.6f\nx2=%.6f\n",x1,x2);
}
}
system("PAUSE");
return EXIT_SUCCESS;
}