mình ko bjk bài của bạn sai chỗ nào nữa, nhưng mình có pót bài này lên nè, chắc xài dk
program ptnt;
var d,x0,x1,x2:real;
a,b,c:integer;
o,p:char;
begin
write('he so a='); readln(a);
write('he so b='); readln(b);
write('he so c='); readln©;
d:=b*b-4*a*c;
x0:=-b/(2*a);
if d>=0 then
begin
x1:=(-b+sqrt(d))/(2*a);
x2:=(-b-sqrt(d))/(2*a);
end;
if a>0 then
o:= char(a+48)
else o:= char (abs(a)+48);
if o='1' then o:=' ';
if (c=0)or (d<0) then writeln('khong phan tich duoc');
if d=0 then
begin
if a>0 then
if (x0<0) then
writeln('A=',o,'(x+',-x0:0:0,')^2')
else
writeln('A=',o,'(x-',x0:0:0,')^2')
else
if (x0<0) then
writeln('A=-',o,'(x+',-x0:0:0,')^2')
else
writeln('A=-',o,'(x-',x0:0:0,')^2');
end;
if d>0 then
begin
if a>0 then
begin
if (x1<0)and(x2<0) then
writeln('A=',o,'(x+',-x1:0:0,')(x+',-x2:0:0,')')
else
if (x1>0)and(x2>0) then
writeln('A=',o,'(x-',x1:0:0,')(x-',x2:0:0,')')
else
if (x1<0)and(x2>0) then
writeln('A=',o,'(x+',-x1:0:0,')(x-',x2:0:0,')')
else
if (x1>0)and(x2<0) then
writeln('A=',o,'(x-',x1:0:0,')(x+',-x2:0:0,')')
end;
if a<0 then
begin
if (x1<0)and(x2<0) then
writeln('A=-',o,'(x+',-x1:0:0,')(x+',-x2:0:0,')')
else
if (x1>0)and(x2>0) then
writeln('A=-',o,'(x-',x1:0:0,')(x-',x2:0:0,')')
else
if (x1<0)and(x2>0) then
writeln('A=-',o,'(x+',-x1:0:0,')(x-',x2:0:0,')')
else
if (x1>0)and(x2<0) then
writeln('A=-',o,'(x-',x1:0:0,')(x+',-x2:0:0,')')
end;
end;
readln;
end.
Bài viết đã được chỉnh sửa nội dung bởi nguyen phat tai: 14-11-2009 - 19:33