Viết chương trình nhập 4 số nguyên và in ra Max ,Min
2 câu trả lời
1)IN RA MAX
program abc;
uses crt;
var a,b,c,d,max:real;
begin
clrscr;
writeln('TIM SO LON NHAT TRONG BON SO A , B ,C , D');
write('nhap a=');
readln(a);
writerite('Nhap b=');
Readln(b);
Write('Nhap c=');
Readln(c);
Write('Nhap d=');
Readln(d);
max:=a;
If b>max then max:=b;
If c>max then max:=c;
if d>max then max:=d;
Writeln('So lon nhat la: ',max: 4: 2);
Readln;
END
2)IN RA MIN
Program TIM_SO_LON_NHAT;
Uses crt;
Var a,b,c,d,min: real;
BEGIN Clrscr;
Writeln('TIM SO NHO NHAT TRONG BON SO A, B, C, D');
Write('Nhap a=');
Readln(a);
Write('Nhap b=');
Readln(b);
Write('Nhap c=');
Readln(c);
Write('Nhap d=');
Readln(d);
max:=a;
If b>max then min:=b;
If c>max then min:=c;
if d>max then min:=d;
Writeln('So lon nhat la: ',min: 4: 2);
Readln;
END.
uses crt;
var a, b, c, d, min, max : integer;
begin
clrscr;
write('Nhap 4 so a, b, c, d : '); readln(a, b, c, d);
max := a; min := a;
if b > max then max := b;
if c > max then max := c;
if d > max then max := d;
if b < min then min := b;
if c < min then min := c;
if d < min then min := d;
writeln('Max = ', max);
writeln('Min = ', min);
readln
end.