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=0,b=0,c=0,delta=0,x1=0,x2=0;
- cout << "f(x) = ax^2+bx+c" << endl;
- cout << "Podaj a" << endl;;
- cin >> a;
- cout << "Podaj b" << endl;;
- cin >> b;
- cout << "Podaj c" << endl;;
- cin >> c;
- delta = (b*b) - 4 *a *c;
- if(delta < 0){
- cout << "Funkcja nie ma miejsc zerowych";
- }else if(delta == 0){
- x1= -(b/2*a);
- cout << "Funkcja ma dokładnie jedno miejsce zerowe x= " << x1 ;
- }else if(delta > 0){
- x1 = ( -(b) - sqrt(delta) ) / (2 * a) ;
- x2 = ( -(b) + sqrt(delta) ) / (2 * a);
- cout << "Miejsce zerowe x1= " << x1 << endl;
- cout << "Miejsce zerowe x2= " << x2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement