0 bình luận về “viết chương trình tìm giá trị tuyệt đối lớn nhất”
program phantucogiatrituyedoi; uses crt; var M: array[1..50] of longint; n,j,tam,i: longint; begin clrscr; write(‘nhap so n= ‘); readln(n); for i:=1 to n do begin write(‘M[‘,i,’]=’); readln(M[i]); end; for i:=1 to n-1 do for j:=i+1 to n do if M[j] < m[i] then begin tam:= m[i]; m[i]:=m[j]; m[j]:=tam; end; if abs(m[1])>abs(m[n]) then writeln(‘gia tri tuyet doi lon nhat=’,abs(m[1])) else writeln(‘gia tri tuyet doi lon nhat=’,abs(m[n])); readln end.
program phantucogiatrituyedoi;
uses crt;
var M: array[1..50] of longint;
n,j,tam,i: longint;
begin
clrscr;
write(‘nhap so n= ‘); readln(n);
for i:=1 to n do
begin
write(‘M[‘,i,’]=’);
readln(M[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if M[j] < m[i] then
begin
tam:= m[i];
m[i]:=m[j];
m[j]:=tam;
end;
if abs(m[1])>abs(m[n]) then writeln(‘gia tri tuyet doi lon nhat=’,abs(m[1]))
else writeln(‘gia tri tuyet doi lon nhat=’,abs(m[n]));
readln
end.
chúc bạn thi tốt xin CTLHN=)