Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int a, b, c, x1, x2, delta; //inicjowanie intów
- cout << "Podaj współczynnik a:" << endl;
- cin >> a;
- cout << "Podaj współczynnik b:" << endl;
- cin >> b;
- cout << "Podaj współczynnik c:" << endl;
- cin >> c;
- if (a==0)
- {
- x1 = -c/b;
- cout << "Wynik to x1:" << endl;
- cout << x1 << endl;
- }
- else
- {
- delta = pow(b,2)-4*a*c;
- if (delta>0)
- {
- x1 = (-b-pow(delta,1/2))/(2*a);
- x2 = (-b+pow(delta,1/2))/(2*a);
- cout << "Wynik to x1:" << endl << x1 << endl;
- cout << "Wynik to x2:" << endl << x2 << endl;
- }
- else if (delta==0)
- {
- x1 = -b/2*a;
- cout << "Wynik to x1:" << endl << x1 << endl;
- }
- else if (delta<0)
- {
- cout << "Brak rozwiązań" << endl << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement