Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vcl.h>
- #include <iostream.h>
- #include <conio.h>
- #include <math.h>
- using namespace std;
- int main()
- {
- int a,b,c,x;
- double x1,x2;
- cout << "Program liczy pierwiastki kwadratowe rownania" << endl;
- cout << "Podaj a:" << endl;
- cin >> a;
- cout << endl;
- cout << "Podaj b:" << endl;
- cin >> b;
- cout << endl;
- cout << "Podaj c:" << endl;
- cin >> c;
- cout << endl;
- cout << "Rownanie ma postac y = " << a << "x^2 + " << b << "x + " << c << endl;
- cout << endl;
- int delta = (b^2)-4*a*c;
- if (delta<0)
- {
- cout << "Delta < 0, wiec brak pierwiastkow rzeczywistych rownania!" << endl;
- getch();
- return 0;
- }
- if (delta>0)
- cout << "Pierwiastki rownania kwadratowego to:" << endl;
- cout << "x1 = " << (-b-(sqrt(delta)))/(2*a) << endl;
- cout << "x2 = " << (-b+(sqrt(delta)))/(2*a) << endl;
- getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment