Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <limits>
- using namespace std;
- double long func(double long a, double long b, double long c, double long x);
- int main()
- {
- setprecision(numeric_limits<long double> ::digits10 + 1);
- //MIEJSCA ZEROWE 3.2
- long double a;
- long double b;
- long double c;
- long double y1, y2;
- cin >> a;
- cin >> b;
- cin >> c;
- long double x1 = (-b - sqrt(b*b - 4 * a * c)) / (2 * a);
- long double x2 = (-b + sqrt(b*b - 4 * a * c)) / (2 * a);
- if(c == 0){
- y1 = 0;
- y2 = -(b/a);
- } else if (b > abs(a * c)) {
- y1 = (-b - sqrt(b*b - 4 * a * c)) / (2 * a);
- y2 = c / (y1 * a);
- } else {
- y1 = (-b + sqrt(b*b - 4 * a * c)) / (2 * a);
- y2 = c / (y1 * a);
- }
- cout << "x1: " << setprecision(5) << x1 << endl;
- cout << "x2: " << setprecision(5) << x2 << endl;
- cout << "y1: " << setprecision(5) << y1 << endl;
- cout << "y2: " << setprecision(5) << y2 << endl;
- cout << "Wartość w x1: " << func(a,b,c,x1) << endl;
- cout << "Wartość w x2: " << func(a,b,c,x2) << endl;
- cout << "Wartość w y1: " << func(a,b,c,y1) << endl;
- cout << "Wartość w y2: " << func(a,b,c,y2) << endl;
- }
- double long func(double long a, double long b, double long c, double long x){
- return (a * (x * x) + (b * x) + c);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement