program BT1;
uses crt;
var a: array[1..200] of integer;
max: integer; n,i: byte;
begin
clrscr;
write('Nhap bao nhieu so:'); readln(n);
for i:=1 to n do begin
write('a[',i,']='); readln(a[i]);
end;
max:= a[1];
for i:=2 to n do if a[i] > max then max:=a[i];
writeln('So lon nhat cua cac so vua nhap la:',max);
readln
end.
2)
Mã:
program BT2;
uses crt;
Var A:array[1..50] Of Integer;
N,i,j,Tam:Integer;
Begin
Write('Nhap N='); Readln(N);
For i:=1 To N Do
Begin
Write('A[',i,']='); Readln(A[i]);
End;
For i:=1 To N-1 Do
For j:=i+1 To N Do
If A[i]>A[j] Then
Begin
Tam:=A[i]; A[i]:=A[j]; A[j]:=Tam;
End;
Writeln('Ket qua sau khi sap xep:');
For i:=1 To N Do Write(A[i]:5);
Readln;
End.