Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- setlocale(LC_CTYPE, "Rus");
- float a, b, c, diskr, d;
- float x1, x2;
- cout << "Введите a:";
- cin >> a;
- cout << "Введите b:";
- cin >> b;
- cout << "Введите c:";
- cin >> c;
- if (a != 0)
- {
- diskr = b * b - (4 * a * c);
- if (diskr >= 0)
- {
- d = sqrt(diskr);
- x1 = (-b + d) / (2 * a);
- x2 = (-b - d) / (2 * a);
- cout << "Рiвняння мае 2 коренi" << endl;
- cout << "x1 = " << x1 << endl;;
- cout << "x2 = " << x2 << endl;;
- }
- else cout << "Не мае дiйсних коренiв";
- }
- else
- {
- if (b != 0)
- {
- cout << "Мае один дiйсний корiнь x1 = " << (c / b) << endl;
- }
- else {
- if (c == 0)
- cout << "Будь-яке число може бути коренем р-ння";
- else
- cout << "Не мое коренiв р-ння";
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement