Ответ:
Как-то так, наверное
Объяснение:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a, x, b, c, D;
cout<<"Введите a: "; cin >> a;
cout<<"Введите b: "; cin >> b;
cout<<"Введите c: "; cin >> c;
D = pow(b,2)-4*a*c;
if(D>0){
cout << "x1 = " << ((-1)*b+sqrt(D))/(2*a)<<endl;
cout << "x2 = " <<((-1)*b-sqrt(D))/(2*a)<<endl;
}
else if(D==0){
cout << "x = " << ((-1)*b)/(2*a)<<endl;
else{
D*=(-1);
cout<< "x1 = " << ((-1)*b)/(2*a) <<"+"<< (sqrt(D))/(2*a) << "*i" <<endl;
cout<< "x2 = " << ((-1)*b)/(2*a) <<"-"<< (sqrt(D))/(2*a) << "*i" <<endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
Как-то так, наверное
Объяснение:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a, x, b, c, D;
cout<<"Введите a: "; cin >> a;
cout<<"Введите b: "; cin >> b;
cout<<"Введите c: "; cin >> c;
D = pow(b,2)-4*a*c;
if(D>0){
cout << "x1 = " << ((-1)*b+sqrt(D))/(2*a)<<endl;
cout << "x2 = " <<((-1)*b-sqrt(D))/(2*a)<<endl;
}
else if(D==0){
cout << "x = " << ((-1)*b)/(2*a)<<endl;
}
else{
D*=(-1);
cout<< "x1 = " << ((-1)*b)/(2*a) <<"+"<< (sqrt(D))/(2*a) << "*i" <<endl;
cout<< "x2 = " << ((-1)*b)/(2*a) <<"-"<< (sqrt(D))/(2*a) << "*i" <<endl;
}
return 0;
}