Tin học Viết thuật toán nhập vào ba số và đưa ra số lớn nhất 27/08/2021 By Brielle Viết thuật toán nhập vào ba số và đưa ra số lớn nhất
write(‘nhap do dai cua day so n=’);readln(n); writeln(‘nhap cac phan tu cua day so :’); for i:=1 to n do begin write(‘a[‘,i,’]=’);readln(a[i]); end; max :=a[1] ; min:=a[1]; for i:=2 to n do begin if max <a[i] then max :=a[i]; if min >a[i] then min :=a[i]; end;writeln(‘so lon nhat la:’,max); writeln(‘so be nhat la:’,min);readln end. Trả lời
write(‘nhap do dai cua day so n=’);readln(n);
writeln(‘nhap cac phan tu cua day so :’);
for i:=1 to n do
begin
write(‘a[‘,i,’]=’);readln(a[i]);
end;
max :=a[1] ; min:=a[1];
for i:=2 to n do
begin
if max <a[i] then max :=a[i];
if min >a[i] then min :=a[i];
end;writeln(‘so lon nhat la:’,max);
writeln(‘so be nhat la:’,min);
readln
end.