Lập phương trình giải pt bậc 2 với các sốa,b,c được đọc từ tệp dulieu.txt nghiệm tìm được in ra ngoài màn hình. Giúp mik vs đag cần lắm ạ

2 câu trả lời

program hotrotinhoc;

const fi='dulieu.txt';

var a,b,c: integer;

procedure ip;

begin

assign(f,fi);

reset(f);

read(f,a,b,c);

close(f);

end;

begin

ip;

out;

end;

readln

end.

program bai_giai;
uses crt;
var f:text;
    a,b,c,denta:integer;
begin
    clrscr;
    Assign(f,'dulieu.txt');  reset(f);
    readln(f,a,b,c);
    denta:=b*b-4*a*c;
    if denta<0 then write('Phuong trinh vo nghiem')
    else if denta=0 then write('Phuong trinh co nghiem kep: x1=x2=',-b/(2*a))
        else
            begin
                writeln('Phuong trinh co hai nghiem phan biet:');
                writeln('x1=',(-b+sqrt(denta))/(2*a));
                writeln('x2=',(-b-sqrt(denta))/(2*a));
            end;
    readln;    close(f);
end.