0
PROGRAMME wich solve EQUATION OF THE SECOND DEGREE
#include <iostream> #include <cmath> using namespace std; int main (){ float a, b, c, d, x1, x2, x; cout << "a="; cin >> a; cout << "b="; cin >> b; cout << "c="; cin >> c; if (a != 0) { d =( b * b )- (4*a*c); if (d > 0) { x1 = (-b - sqrt(d)) / (2 * a); cout << "x1=" << x1; x2 = (-b + sqrt(d)) / (2 * a); cout << "x2=" << x2; } else if (d == 0) { x = -b / (2 * a); cout << "x=" << x; } else { cout << "no solution"; } } return 0; }
1 Antwort