15 lines
327 B
Matlab
15 lines
327 B
Matlab
% x=input('please type a number \n');
|
|
% if fix(x) == x
|
|
% disp(x);
|
|
% end
|
|
|
|
a = input('a=?');
|
|
b = input('b=?');
|
|
c = input('c=?');
|
|
d = b * b - 4 * a * c ;
|
|
if d > 0
|
|
x = [(-b + sqrt(d))/(2 * a),(-b - sqrt(d))/(2 * a)];
|
|
disp(['x1=',num2str(x(1)),'x2=',num2str(x(2))]);
|
|
else
|
|
disp('无解!!! 请重新输入');
|
|
end |