Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- float a,b,c,D,x1r,x1i,x2r,x2i;
- cout<<"unesite koeficijete a,b,c:"<<endl;
- cin>>a>>b>>c;
- D = b*b - 4*a*c;
- if (D >= 0) {
- x1r = (-b+sqrt(D))/(2*a);
- x2r = (-b-sqrt(D))/(2*a);
- cout<<"Rjesenja jednacine su realna"<<endl;
- cout<<"x1 = "<<x1r<<endl;
- cout<<"x2 = "<<x2r<<endl;
- }
- else {
- x1r = -b/(2*a);
- x1i = sqrt(-D)/(2*a);
- x2r = -b/(2*a);
- x2i = -sqrt(-D)/(2*a);
- cout<<"Rjesenja jednacine su iracionalna"<<endl;
- cout<<"x1r = "<<x1r<<" x1i = "<<x1i<<"i"<<endl;
- cout<<"x2r = "<<x2r<<" x2i = "<<x2i<<"i"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment