Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- double a, b, c, delta;
- cout<<endl;
- cout<<"STABILNY ALGORYTM OBLICZAJACY ROWNANIE KWADRATOWE" <<endl<<endl<<endl;
- cout << "Podaj a, b, c:" << endl;
- cout<<"a= ";
- cin>>a;
- cout<<"b= ";
- cin>>b;
- cout<<"c= ";
- cin>>c;
- delta=pow(b,2)-4*a*c;
- cout<<endl;
- if (a==0)
- {
- cout<<"To nie jest rownanie kwadratowe!!!" <<endl;
- }
- else if (delta<0)
- {
- cout<<"Rownanie nie ma pierwiastkow" <<endl;
- }
- else if (delta==0)
- {
- double x= -b/(2*a);
- cout<<"Rozwiazanie to: "<<x;
- cout<<endl;
- }
- else
- {
- double pom=c/a;
- if(b>0)
- {
- double x1=(-b-sqrt(delta))/(2*a);
- double x2=pom/x1;
- cout<<"Rozwiazania to: "<<x1<<" oraz "<<x2<<endl;
- cout<<endl;
- }
- else
- {
- double x2=(-b+sqrt(delta))/(2*a);
- double x1=pom/x2;
- cout<<"Rozwiazania to: "<<x1<<" oraz "<<x2<<endl;
- cout<<endl;
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement