2个回答
展开全部
4处错误!
a=input('enter the coefficientA:');
b=input('enter the coefficientB:');
c=input('enter the coefficientC:');
if (b^2-4*a*c)>0
x1=(-b+sqrt(b^2-4*a*c))/(2*a);
x2=(-b-sqrt(b^2-4*a*c))/(2*a);
disp('this question has two distinct real roots');
sprintf('x1 = %f\n', x1) % 1
sprintf('x2 = %f\n', x2)
elseif (b^2-4*a*c)==0 % 3
x1=(-b)/(2*a);
disp('this question has two identical real roots');
sprintf('x1=x2=%f\n',x1)
else (b^2-4*a*c)<0
disp('This equation has complex roots:');
end
a=input('enter the coefficientA:');
b=input('enter the coefficientB:');
c=input('enter the coefficientC:');
if (b^2-4*a*c)>0
x1=(-b+sqrt(b^2-4*a*c))/(2*a);
x2=(-b-sqrt(b^2-4*a*c))/(2*a);
disp('this question has two distinct real roots');
sprintf('x1 = %f\n', x1) % 1
sprintf('x2 = %f\n', x2)
elseif (b^2-4*a*c)==0 % 3
x1=(-b)/(2*a);
disp('this question has two identical real roots');
sprintf('x1=x2=%f\n',x1)
else (b^2-4*a*c)<0
disp('This equation has complex roots:');
end
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询