0 bình luận về “Giải pt bậc nhất trong Pascal ax +b =0”
uses crt; var a,b:extended; {—a=0—} procedure TH1; begin writeln(‘PT co vo so nghiem’); end; {———} procedure TH1_1; begin writeln(‘PT vo nghiem’); end; {—a<>0—} procedure TH2; begin writeln(‘PT co 1 nghiem duy nhat: x=’,-b/a:0:2); end; {—Chuong-trinh-chinh—} BEGIN clrscr; write(‘Nhap a,b: ‘); readln(a,b); if a=0 then if b=0 then TH1 else TH1_1 else TH2; readln; END.
uses crt;
var a,b:extended;
{—a=0—}
procedure TH1;
begin
writeln(‘PT co vo so nghiem’);
end;
{———}
procedure TH1_1;
begin
writeln(‘PT vo nghiem’);
end;
{—a<>0—}
procedure TH2;
begin
writeln(‘PT co 1 nghiem duy nhat: x=’,-b/a:0:2);
end;
{—Chuong-trinh-chinh—}
BEGIN
clrscr;
write(‘Nhap a,b: ‘); readln(a,b);
if a=0 then if b=0 then TH1
else TH1_1
else TH2;
readln;
END.
uses crt;
var a,b:longint;
begin
clrscr;
readln(a,b);
if (a=0) and (b=0) then write(‘Pt co vo so No’);
if (a=0) and (b<>0) then write(‘Pt vo No’);
if (a<>0) and (b<>0) then write(‘Pt co nghiem x= ‘,-b/a:10:2);
readln
end.