Kod: Zaznacz cały
#include <iostream>
#include <math.h>
#include <cstdlib>
using namespace std;
int main()
{
float a;
float b;
float c;
float delta;
float x1;
float x2;
float x;
cout << "Podaj a: ";
cin >> a;
if(a==0) cout << "Rownanie nie jest kwadratowe
";
else
{
{
cout << "Podaj b: ";
cin >> b;
cout << "Podaj c: ";
cin >> c;
delta=b*b-4*a*c;
cout << "Delta wynosi: " << delta << endl;
}
{
if(delta>0)
{
x1=-b-sqrt(delta)/2*a;
x2=-b+sqrt(delta)/2*a;
cout << "Pierwszy pierwiastek wynosi: " << x1 << endl;
cout << "Drugi pierwiastek wynosi: " << x2 << endl;
}
else if(delta==0)
{
x=-b/2*a;
cout << "Pierwiastek podwojny wynosi: " << x << endl;
}
else if(delta<0)
{
cout << "Rownanie nie ma pierwiastkow
";
}
}
}
cout << endl;
system("pause");
return 0;
}