Viết chương trình giải phương trình ax2 + bx + c = 0 a=0

60 điểm

NguyenChiHieu

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

Tổng hợp câu trả lời [1]

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]; Trang 2 If a=0 then If b=0 then If c=0 then Writeln['Phuong trinh co vo so nghiem'] Else Else Writeln['Phuong trinh vo nghiem'] Else Begin Writeln['Phuong trinh co mot nghiem: x=',-c/b:4:2] 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

Giải phương trình bậc 2 [ax2+ bx + c =0]

Program GIAI_PHUONG_TRINH_BAC_HAI;
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 d

Chủ Đề