Помогите, пожалуйста!!! Проанализируйте задачу решения биквадратного уравнения, составьте алгоритм и напишите программу на Паскале.
Answers & Comments
fasalvvar a, b, c, D, x, y: real; begin readln(a, b, c); {ax^4 + bx^2 + c = 0} if a = 0 then writeln('Non-bisquare') else begin D := b * b - 4 * a * c; if D < 0 then writeln('No solutions') else begin if D = 0 then begin x := -b / 2 / a; if x < 0 then writeln('No solutions') else writeln('2 solutions: ', sqrt(x), ' ', -sqrt(x)); end else begin x := (-b + sqrt(D)) / 2 / a; y := (-b - sqrt(D)) / 2 / a; if x < 0 then writeln('No solutions'); if x = 0 then writeln('1 solution: 0'); if (x > 0) and (y < 0) then writeln('2 solutions: ', sqrt(x):0:3, ' ', -sqrt(x):0:3); if (x > 0) and (y = 0) then writeln('3 solutions: ', sqrt(x):0:3, ' ', -sqrt(x):0:3, ' 0'); if y > 0 then writeln('4 solutions: ', sqrt(x):0:3, ' ', -sqrt(x):0:3, ' ', sqrt(y):0:3, ' ', -sqrt(y):0:3); end; end; end; end.
Answers & Comments
begin
readln(a, b, c); {ax^4 + bx^2 + c = 0}
if a = 0 then
writeln('Non-bisquare')
else
begin
D := b * b - 4 * a * c;
if D < 0 then
writeln('No solutions')
else
begin if D = 0 then
begin x := -b / 2 / a;
if x < 0 then
writeln('No solutions')
else writeln('2 solutions: ', sqrt(x), ' ', -sqrt(x));
end
else
begin x := (-b + sqrt(D)) / 2 / a;
y := (-b - sqrt(D)) / 2 / a;
if x < 0 then writeln('No solutions');
if x = 0 then
writeln('1 solution: 0');
if (x > 0) and (y < 0) then
writeln('2 solutions: ', sqrt(x):0:3, ' ', -sqrt(x):0:3);
if (x > 0) and (y = 0) then
writeln('3 solutions: ', sqrt(x):0:3, ' ', -sqrt(x):0:3, ' 0');
if y > 0 then
writeln('4 solutions: ', sqrt(x):0:3, ' ', -sqrt(x):0:3, ' ', sqrt(y):0:3, ' ', -sqrt(y):0:3);
end;
end;
end;
end.