Κώδικας: Επιλογή όλων
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a,b,c,d,e,f,r,x1,x2,D;
cout << "Welcome to Eagle's solver of the quadratic equations\n";
cout << "The basic type is: ax^2 + bx + c = 0\n";
cout << "Write the a(ONLY NUMBER!)";
cin >> a;
cout << "Write the b(ONLY NUMBERS!)";
cin >> b;
cout << "Write the c(ONLY NUMBER!)";
cin >> c;
if(a==0.0){
d=(-c/b);
cout << "Result:-" << c << "/" << b << endl;
cout << "Result:" << d << endl;
return 1;
}else if(b==0.0){
e=(-c/a);
f=(sqrt(e));
cout << "Result:Root(-" << c << "/" << a << ")" << endl;
cout << "Result:" << f << endl;
return 1;
}else if(a==0.0&&b==0.0&&c==0.0){
cout << "Result:0";
return 1;
}
D=((b*b)-(4.00*a*c));
cout << "Now we find the disrcriminant\n";
cout << "The basic type is: D=b^2-4ac\n";
cout << "D=" << b*b << "-4*" << a << "*" << c << endl;
cout << "D=" << D << endl;
if(D>=0.0){
r=sqrt(D);
x1=((-b+r)/(2*a));
x2=((-b-r)/(2*a));
cout << "The equations has got two(2) solves!\n";
cout << "Solve 1:-" << b << "+root[" << D << "/2*" << a << "]" << endl;
cout << "solve 1:" << x1 << endl;
cout << "Solve 2:-" << b << "-root[" << D << "/2*" << a << "]" << endl;
cout << "Solve 2:" << x2 << endl;
}else{
cout << "The equations is impossible\n";
}
system("PAUSE");
return 0;
}