5A_4
This commit is contained in:
parent
2b05a55d85
commit
3e7e6a7200
|
@ -1,8 +1,29 @@
|
|||
#include <iostream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << "Hello World!" << endl;
|
||||
}
|
||||
cout << setprecision(2);
|
||||
float a, b, c;
|
||||
cout << "Podaj a: ", cin >> a;
|
||||
cout << "Podaj b: ", cin >> b;
|
||||
cout << "Podaj c: ", cin >> c;
|
||||
|
||||
cout << "Rownanie: " << a << "x^2 + " << b << "x + " << c << " = 0" << endl;
|
||||
|
||||
float delta = (b * b) - (4 * a * c);
|
||||
if (delta < 0) cout << "Brak pierwiastkow" << endl;
|
||||
else if (delta == 0) {
|
||||
float x = -b / (2 * a);
|
||||
cout << "1 pierwiastek: x = " << x << endl;
|
||||
}
|
||||
else {
|
||||
float x1, x2;
|
||||
float sq = sqrt(delta);
|
||||
x1 = (-b - sq) / (2 * a);
|
||||
x2 = (-b + sq) / (2 * a);
|
||||
cout << "2 pierwiastki: x1 = " << x1 << ", x2 = " << x2 << endl;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue