Chương trình giải phương trình bậc 2 pascal

Program GIAI_PHUONG_TRINH_BACII;
Uses crt;
Var a,b,c,d,x,x1,x2: real;
Begin
  Clrscr;
  Writeln['GIAI PHUONG TRINH BAC II: '];
  Writeln['-------------------------------------------'];
  Write['Nhap he so a=']; readln[a];
  Write['Nhap he so b=']; readln[b];
  Write['Nhap he so c=']; readln[c];
  If a=0 then
    If b=0 then
      If c=0 then
        Writeln['Phuong trinh co vo so nghiem']
      Else Writeln['Phuong trinh vo nghiem']
    Else Writeln['Phuong trinh co mot nghiem: x=',-c/b: 4: 2]
  Else
    Begin
      D:=b*b-4*a*c;
      If D=0 then Writeln['Phuong trinh co nghiem kep: x=',-b/[2*a]: 4: 2]
      Else
        If D=0’];

Writeln[‘———————————————————————-‘];

Write[‘nhap a=’];readln[a];

Write[‘nhap b=’];readln[b];

If a0 then

If a>0 then Writeln[‘Bat phuong trinh co nghiem: x>=’,-b/a:4:2] Else Writeln[‘Bat phuong trinh co nghiem: x=0 then Writeln[‘Bat phuong trinh co vo so nghiem’] Else writeln[‘Bat phuong trinh vo nghiem’]; Readln;

End.

Bài 6: Viết chương trình giải phương trình bậc 2 [ax2 + bx + c =0]

Program GIAI_PHUONG_TRINH_BACII;

Uses crt;

Var a,b,c,d,x,x1,x2:real;

Begin

Writeln [‘GIAI PHUONG TRINH BAC II:’]; Writeln[‘——————————————-‘];

Write [‘Nhap he so a=’];readln[a];

Write [‘Nhap he so b=’];readln[b]; Write[‘Nhap he so c=’];readln[c];

If a=0 then

If b=0 then

If c=0 then Writeln [‘Phuong trinh co vo so nghiem’] Else Writeln [‘Phuong trinh vo nghiem’]

Else Writeln [‘Phuong trinh co mot nghiem: x=’,-c/b:4:2]

Else

Begin

d:=b*b-4*a*c;

If d=0 then

Writeln[‘Phuong trinh co nghiem kep: x=’,-b/[2*a]:4:2] Else

If dmax then max:=b; If d>max then max:=d;

Writeln [‘So lon nhat la:’,max:4:2]; Readln;

Bài 8: Tìm giá trị nhỏ nhất trong 4 số a, b, c, d [a, b, c, được nhập từ bàn phím].

Program TIM_SO_NHO_NHAT;

Uses crt;

Var a,b,c,d,min:real; Begin

Clrscr;

Writeln [‘TIM SO NHO NHAT TRONG BON SO A, B, C, D’];

End.

Writeln [‘—————————————————————‘];

Write [‘Nhap a=’]; Readln[a];

Write [‘Nhap b=’]; Readln[b];

Write [‘Nhap c=’]; Readln[c];

Write [‘Nhap d=’]; Readln[d]; min:=a;

If b

Chủ Đề