08/01/23 18:58:15
>>773
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
double a,b,c,d;
cout << "a=";cin >> a;
cout << "b=";cin >> b;
cout << "c=";cin >> c;
d=b*b-4*a*c;
if(d==0)
{
double x;
x=-b/(2*a);
cout << "x=" << x << endl;
}
else if(d>0)
{
double x1,x2;
x1=(-b+sqrt(d))/(2*a);x2=(-d-sqrt(d))/(2*a);
cout << "x1=" << x1 << "\nx2=" << x2 << endl;
}
else
{
double xa,xb;
xa=-d/(2*a);xb=sqrt(-d)/(2*a);
cout << "x1=" << xa << "+" << xb << "i\nx2=" << xa << "-" << xb << "i" << endl;
}
}