viết chương trình giải phương trình bậc nhất một ẩn ax +b =0, a,b nhập từ bàn phím 23/08/2021 Bởi Hadley viết chương trình giải phương trình bậc nhất một ẩn ax +b =0, a,b nhập từ bàn phím
Program Hotboy ; Uses crt; Var a,b,x : integer; Begin Clrscr Write(‘ giai phuong trinh bac nhat ax+b=0’); Write(‘ nhap so a’,a); Readln(a); Write(‘nhap so b’,b); Readln(b) If a<>0 then x:=-b/a; Write(‘phuong trinh co 1 nghiem duy nhat la’,x:2:2) Else If a=0 and b=0 then write(‘ phuong trinh co vo so nghiem’); If a=0 and b<>0 then Write(‘phuong trinh vo nghiem’); Readln End. Bình luận
Uses Crt; Var a,b,x : real; Begin Write(‘a = ‘); Readln(a); Write(‘b = ‘); Readln(b); If a = 0 Then If b = 0 Then Writeln(‘Phuong trinh co vo so nghiem’) Else Writeln(‘Phuong trinh vo nghiem’) Else Begin x:= -b/a; Writeln(‘Phuong trinh co nghiem la :’,x:0:2); End; Readln; End. Bình luận
Program Hotboy ;
Uses crt;
Var a,b,x : integer;
Begin
Clrscr
Write(‘ giai phuong trinh bac nhat ax+b=0’);
Write(‘ nhap so a’,a);
Readln(a);
Write(‘nhap so b’,b);
Readln(b)
If a<>0 then
x:=-b/a;
Write(‘phuong trinh co 1 nghiem duy nhat la’,x:2:2)
Else
If a=0 and b=0 then write(‘ phuong trinh co vo so nghiem’);
If a=0 and b<>0 then
Write(‘phuong trinh vo nghiem’);
Readln
End.
Uses Crt;
Var a,b,x : real;
Begin
Write(‘a = ‘); Readln(a);
Write(‘b = ‘); Readln(b);
If a = 0 Then
If b = 0 Then
Writeln(‘Phuong trinh co vo so nghiem’)
Else
Writeln(‘Phuong trinh vo nghiem’)
Else
Begin
x:= -b/a;
Writeln(‘Phuong trinh co nghiem la :’,x:0:2);
End;
Readln;
End.