Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- cout << "Podaj liczbe a: ";
- int a, b, c;
- cin >> a;
- cout << "Podaj liczbe b: ";
- cin >> b;
- cout << "Podaj liczbe c: ";
- cin >> c;
- int delta = b*b-4*a*c;
- if (delta < 0)
- {
- cout << "Brak rozwiazan";
- }
- else
- {
- float pierw = sqrt(delta);
- float x1 = (-b-pierw)/2*a;
- if (delta == 0)
- {
- cout << "x = " << x1;
- }
- else
- {
- float x2 = (-b+pierw)/2*a;
- cout <<"x1 = " << x1 << endl << "x2 = " << x2;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement