100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 习题3.3--C语言程序设计第三版课后习题(苏小红)

习题3.3--C语言程序设计第三版课后习题(苏小红)

时间:2024-02-02 22:14:21

相关推荐

习题3.3--C语言程序设计第三版课后习题(苏小红)

计算一元二次方程的两个实根 x1,x2

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main()

{

float a,b,c,temp,x1,x2;

printf("please input number:");

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

temp = sqrt(b*b - 4*a*c);

if(temp > 0)

{

x1 = ((-b)+temp)/(2*a);

x2 = (b+temp)/(2*a);

printf("the value of x1 and x2 is :%d, %d\n",x1,x2);

}

else

printf("the value of x1 and x2 is error\n");

return 0;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。