Câu 1:
PROGRAM TIM_MAX;
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A:Mang;
N,i,Max:Integer;
BEGIN
Write('Nhap N='); 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 Max<A[i] Then Max:=A[i];
Writeln('Phan tu lon nhat cua mang:', Max);
Readln;
END.
Câu 2:
PROGRAM TIM_MIN;
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A: Mang;
N, i, Min: Integer;
BEGIN
Write('Nhap N='); Readln(N);
For i:=1 To N Do
Begin
Write('A[',i,']= '); Readln(A[i]);
End;
Min:=A[1];
For i:=2 To N Do
If Min>A[i] Then Min:=A[i];
Writeln('Phan tu nho nhat cua mang la:', Min);
Readln;
END.
PROGRAM EVEN_COUNT;
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A: Mang;
N, i, Count :Integer;
BEGIN
Write('Nhap N='); Readln(N);
For i:=1 To N Do
Begin
Write('A[',i,']='); Readln(A[i]);
End;
Count :=0;
For i :=1 To N Do
If A[i] mod 2 = 0 Then Count:=Count + 1;
Writeln('So phan tu chan trong day so la: ', Count);
Readln;
END.
Câu 4:
PROGRAM TINH_TONG;
Uses Crt;
Type Mang = ARRAY[1..50] Of Integer;
Var A: Mang;
N, i, Sum: Integer;
BEGIN
Repeat Write('Nhap N='); Readln(N);
until (N>0) and (N<=50)
For i:=1 To N Do
Begin
Write('A[',i,']='); Readln(A[i]);
End;
Sum:=A[1];
For i:=2 To N Do Sum:= Sum + A[i];
Writeln('Tong cac phan tu cua mang la:', Sum);
Readln;
END.