Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <math.h>
- float kwadrat(float x, float y, float z, float &k, float &l)
- {
- float delta;
- delta = pow(y,2) - 4 *x*z;
- if (delta<0)
- return 1;
- if (delta == 0)
- {
- k = (-y)/(2*x);
- l = (-y)/(2*x);
- return 2;
- }
- if (delta>0)
- {
- k = (-y-sqrt(delta))/(2*x);
- l = (-y+sqrt(delta))/(2*x);
- return 3;
- }
- }
- float a, b, c, x1, x2;
- float& ref1;
- float& ref2;
- int d;
- int main()
- {
- using namespace std;
- ref1=x2;
- ref2=x2;
- cout << "Podaj wspolczynniki przy odpowiednich potęgach" << endl;
- cout << "a= ";
- cin >> a;
- if (a == 0)
- cout << "To nie jest funkcja kwadratowa."; << endl;
- if (a!=0)
- {
- cout << "b= ";
- cin >> b;
- cout << "c= ";
- cin >> c;
- d= kwadrat(a, b, c, ref1, ref2);
- }
- if (d == 1)
- cout << "Brak rozwiazan";
- if (d == 2)
- cout << "x=" << x1;
- if (d == 3)
- cout << "x1=" << x1 << "x2=" << x2;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement