Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int a, // uhiuhiuhiu
- b, // uiguyigig
- c; // jkhkjhkjhkjh
- int discriminant();
- ///////////////////////////////////////////////////////
- int main()
- {
- setlocale(LC_ALL, "rus");
- cout << "Введите через пробел коэффициенты A, B и C: ";
- cin >> a >> b >> c;
- int D = discriminant();
- if(D < 0)
- {
- cout << "У этого уравнения нет решений! (D = " << D << ")\n";
- }
- float x1, x2;
- if(D == 0)
- {
- x1 = -1 * b/(2*a);
- cout << "x1 = " << x1 << endl;
- }
- if(D > 0)
- {
- x1 = ( -1*b + sqrt(D) ) / (2 * a);
- cout << "x1 = " << x1 << " ";
- x2 = ( -1*b - sqrt(D) ) / (2 * a);
- cout << "x2 = " << x2 << endl;
- }
- return 0;
- }
- /////////////////////////////////////////////////////////
- int discriminant() //
- {
- int p1 = b*b;
- int p2 = 4*a*c;
- return p1 - p2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement