Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int dis(int a, int b, int c) {
- return b * b - (4 * a * c);
- }
- int X1(int b, int d, int a) {
- return (-b + sqrt(d)) / (2 * a);
- }
- int main() {
- int a, b, c, d, x1, x2;
- cin >> b >> a >> c;
- d = dis(b, a, c);
- cout << "D = " << d << endl;
- if (d < 0) {
- cout << "Нет решений." << endl;
- }
- else
- if (d == 0) {
- x1 = X1(b, d, a);
- cout << "x1 = " << x1 << endl;
- }
- else
- x1 = X1(b, d, a);
- x2 = (-b - sqrt(d)) / (2 * a);
- cout << "x1 = " << x1 << endl << "x2 = " << x2 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement