20_求一元二次方程的根

来源:互联网 发布:c windows temp 编辑:程序博客网 时间:2024/05/02 20:11
//2012年9月29日17:46:17#include <iostream>#include <cmath>using namespace std;int main(){float a, b, c, x1, x2;cin>>a>>b>>c;x1 = (-b + sqrt(b*b-4*a*c))/(a*2);x2 = (-b - sqrt(b*b-4*a*c))/(a*2);cout<<"x1 = "<<x1<<endl;cout<<"x2 = "<<x2<<endl;return 0;}//不能判断是否有根

原创粉丝点击