解题思路:就数学公式的基本应用
注意事项:
参考代码:
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
double x1,x2,a,b,c,d;
cin>>a>>b>>c;
d=b*b-4*a*c;
if(d!=0)
{
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
}
else
{
x1=x2=-b/(2*a);
}
if(abs(x1)>abs(x2)) swap(x1,x2);
cout<<fixed<<setprecision(2)<<x1<<" "<<x2;
return 0;
}
0.0分
1 人评分
1128题解(返回值为数组的情况)浏览:474 |
循环入门练习5 (C语言代码)浏览:839 |
小九九 (C语言描述,不看要求真坑爹)浏览:985 |
C二级辅导-分段函数 (C语言代码)浏览:601 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:345 |
字符串的输入输出处理 (C语言代码)浏览:1016 |
The 3n + 1 problem (C语言代码)浏览:505 |
Tom数 (C语言代码)浏览:555 |
回文数(一) (C语言代码)浏览:1120 |
统计立方数 (C语言代码)浏览:865 |