Nhập dãy in số lớn nhất, số các số chẵn, tổng các số chẵn 17/07/2021 Bởi Hadley Nhập dãy in số lớn nhất, số các số chẵn, tổng các số chẵn
program Day; use crt; var A:array [1..500] of integer; n,i,max,d,T: integer; Begin clrscr; write(‘Nhap so phan tu: ‘); readln(n); max:=1; for i:=1 to n do begin write(‘A[‘,i,’]=’); readln(A[i]); if max<A[i] then max:=A[i]; if A[i] mod 2=0 then begin d:=d+1; T:=T+A[i]; end; end; writeln(‘So lon nhat: ‘,max); writeln(‘Co ‘,d,’ so chan’); write(‘Tong cac so chan cua day = ‘,T); readln End. Bình luận
program bai_giai; uses crt; var A:array[1..1000] of integer; n,i,d,max,t:integer; begin clrscr; write(‘Nhap so luong phan tu: ‘); readln(n); for i:=1 to n do begin write(‘Nhap so thu ‘,i,’: ‘); readln(A[i]); end; max:=A[1]; for i:=1 to n do begin if A[i]>max then max:=A[i]; if A[i] mod 2=0 then begin d:=d+1; t:=t+A[i]; end; end; writeln(‘So lon nhat la ‘,max); writeln(‘So cac so chan la: ‘,d); writeln(‘Tong cac so chan la: ‘,t); readln; end. Bình luận
program Day;
use crt;
var A:array [1..500] of integer;
n,i,max,d,T: integer;
Begin
clrscr;
write(‘Nhap so phan tu: ‘); readln(n);
max:=1;
for i:=1 to n do
begin
write(‘A[‘,i,’]=’); readln(A[i]);
if max<A[i] then max:=A[i];
if A[i] mod 2=0 then
begin
d:=d+1;
T:=T+A[i];
end;
end;
writeln(‘So lon nhat: ‘,max);
writeln(‘Co ‘,d,’ so chan’);
write(‘Tong cac so chan cua day = ‘,T);
readln
End.
program bai_giai;
uses crt;
var A:array[1..1000] of integer;
n,i,d,max,t:integer;
begin
clrscr;
write(‘Nhap so luong phan tu: ‘); readln(n);
for i:=1 to n do
begin
write(‘Nhap so thu ‘,i,’: ‘); readln(A[i]);
end;
max:=A[1];
for i:=1 to n do
begin
if A[i]>max then max:=A[i];
if A[i] mod 2=0 then
begin
d:=d+1;
t:=t+A[i];
end;
end;
writeln(‘So lon nhat la ‘,max);
writeln(‘So cac so chan la: ‘,d);
writeln(‘Tong cac so chan la: ‘,t);
readln;
end.