Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://vk.com/evgenykravchenko0
- ___ ___ ___
- / /\ ___ / /\ / /\
- / /:/_ /__/\ / /:/_ / /:/_
- / /:/ /\ \ \:\ / /:/ /\ / /:/ /\
- / /:/ /:/_ \ \:\ / /:/_/::\ / /:/ /:/_
- /__/:/ /:/ /\ ___ \__\:\ /__/:/__\/\:\ /__/:/ /:/ /\
- \ \:\/:/ /:/ /__/\ | |:| \ \:\ /~~/:/ \ \:\/:/ /:/
- \ \::/ /:/ \ \:\| |:| \ \:\ /:/ \ \::/ /:/
- \ \:\/:/ \ \:\__|:| \ \:\/:/ \ \:\/:/
- \ \::/ \__\::::/ \ \::/ \ \::/
- \__\/ ~~~~ \__\/ \__\/
- ___
- /__/\ ___ ___
- \ \:\ / /\ / /\
- \ \:\ / /:/ / /:/
- _____\__\:\ /__/::\ /__/::\
- /__/::::::::\ \__\/\:\__ \__\/\:\__
- \ \:\~~\~~\/ \ \:\/\ \ \:\/\
- \ \:\ ~~~ \__\::/ \__\::/
- \ \:\ /__/:/ /__/:/
- \ \:\ \__\/ \__\/
- \__\/
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- float a; // 1-й коэффициент
- float b; // 2-ой коэффициент
- float c; // Свободный коэффициент
- float D = 0; // Дискриминант
- float x1 = 0;// 1-й корень уравнения
- float x2 = 0;// 2-ой корень уравнения
- //ax^2 + bx + c = 0
- printf("Введите коэффициет а : ");
- scanf("%f", &a);
- printf("Введите коэффициет b : ");
- scanf("%f", &b);
- printf("Введите коэффициет c : ");
- scanf("%f", &c);
- if (a == 0) exit(0);
- //break;
- if (a != 0 && b != 0 && c != 0)
- {
- D = b * b - 4 * a * c;
- if (D < 0) exit(0);
- //break;
- x1 = (-b + sqrt(D)) / (2 * a);
- x2 = (-b - sqrt(D)) / (2 * a);
- }
- if (b == 0 && c == 0)
- { //ax^2 = 0
- x1 = 0;
- x2 = 0;
- }
- else if (b == 0 || c == 0)
- {
- if (c == 0)
- { //ax^2 + bx = 0
- x1 = 0;
- x2 = -b / a;
- }
- else if (b == 0)
- { //ax^2 + c = 0
- x1 = sqrt(-c / a);
- x2 = -sqrt(-c / a);
- }
- }
- printf("x1 = %f \n", x1);
- printf("x2 = %f \n", x2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement