Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- double a{}, b{}, c{}, x{};
- cout << "***********************" << endl;
- cout << "Podaj a =";
- cin >> a;
- cout << "Podaj b =";
- cin >> b;
- cout << "Podaj c =";
- cin >> c;
- cout << "***********************" << endl;
- cout << "Podaj x = ";
- cin >> x;
- cout << "***********************" << endl;
- if (a < 0) {
- if (a == -1)
- cout << "-x^2";
- else
- cout << a << "x^2";
- }
- else if (a > 0)
- if (a == 1)
- cout << "x^2";
- else
- cout << a << "x^2";
- if (b < 0) {
- if (b == -1)
- cout << "-x";
- else
- cout << b << "x";
- }
- else if (b > 0) {
- if(a==0)
- if(a==1)
- cout << "x";
- else
- cout << b << "x";
- else
- if(a==1)
- cout << "+" << "x";
- else
- cout << "+" << b << "x";
- }
- else;
- if (c < 0)
- cout << c;
- else if (c > 0) {
- if (b == 0 && a==0)
- cout << c;
- else
- cout << "+" << c;
- }
- else;
- cout << endl;
- double result{};
- result = a * x *x + b * x + c;
- cout << "***********************" << endl;
- cout << "f(" << x << ")=" << result<<endl;
- cout << "***********************" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement