a006.
一元二次方程式
| From: [218.173.130.42] |
發表日期
:
2010-07-28 00:17
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double a,b,c,x1,x2,d;
d = b*b-4*a*c;
x1 = (-b+sqrt(d))/2/a;
x2 = (-b-sqrt(d))/2/a;
while(cin >> a >> b >> c){
if(d>0)
cout << "Two different roots x1=" << x1 << " , x2=" << x2 << endl;
else if(d == 0)
cout << "Two same roots x=" << x1 << endl;
else
cout << "No real root" << endl;
}
system("PAUSE");
return 0;
}