a006.
一元二次方程式
| From: [122.127.66.241] |
發表日期
:
2011-03-26 19:46
#include<<math.h>>
#include<iostream>
using namespace std;
int main ()
{
int a,b,c,d,e,f;
while (cin >> a >> b >> c )
d=(-b+sqrt(b*b-4*a*c))/2*a
e=(-b-sqrt(b*b-4*a*c))/2*a
f=(-b)/2*a
if (b*b-4*a*c > 0)
{
cout << "Two different roots x1=" << d << ", x2=" << e << endl;
}
else if (b*b-4*a*c=0)
{
cout << "Two same roots x=" << f << endl;
}
else
{
cout << "No real root" << endl ;
}
}