Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include<cmath>
- int main()
- {
- float a, b, c, x1, x2, D, eps = 0.001;
- std::cout << "VVedit koeficientu" << "\n";
- std::cin >> a >> b >> c;
- if (a == 0 && b == 0 && c == 0) {
- std::cout << "rivnanja pogano obymovlene" << "\n";
- system("pause");
- exit;
- }
- else if (a == 0 && b != 0 && c != 0) {
- float x;
- //bx+c=0
- //x=-c/b
- x = -c / b;
- std::cout << "x= " << x << "\n";
- system("pause");
- exit;
- }
- else if (a == 0 && b == 0 && c != 0) {
- std::cout << "Rivnanja ne mae rozvjazkiv" << "\n";
- system("pause");
- exit;
- }
- else {
- D = b*b - 4 * a*c;
- if (D < 0) {
- std::cout << "rivnaja ne maje rozvjazkiv" << "\n";
- system("pause");
- }
- else if (abs(D) < eps) {
- float x;
- x = (-b / (2 * a));
- std::cout << "x = " << x << "\n";
- }
- else
- {
- x1 = (-b + sqrt(D)) / (2 * a);
- x2 = (-b - sqrt(D)) / (2 * a);
- std::cout << "x1=" << x1 << "\n" << "x2=" << x2 << "\n";
- system("pause");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement