Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
uses crt;
var a:array[1..100]of integer;
n,i,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 2<>0 then
begin
write(a[i]:4);
inc(dem);
end;
writeln;
writeln('So so le la: ',dem);
readln;
end.
program TongChanLe;
var
n,i, chans, les: integer; a: array[1..100] of integer;
begin
chans := 0;
les := 0;
write('Nhap n: ');
readln(n);
for i:=1 to n do
begin
write('Nhap so thu ', i, ': ');
readln(a[i]);
if a[i] mod 2 = 0 then
chans := chans + a[i]
else
les := les + a[i];
end;
writeln('Tong cac so chan la: ', chans);
writeln('Tong cac so le la: ', les);
readln;
end.
program BaiTap;
var
A: array[1..150] of integer;
N, i, sum: integer;
begin
write('Nhap so phan tu cua day A (N <= 150): ');
readln(N);
for i := 1 to N do
begin
write('Nhap phan tu thu ', i, ': ');
readln(A[i]);
end;
writeln('Day so vua nhap la:');
for i := 1 to N do
write(A[i], ' ');
writeln;
sum := 0;
for i := 1 to N do
if A[i] mod 2 = 0 then
sum := sum + A[i];
writeln('Tong cac phan tu chan trong day la: ', sum);
readln;
end.
Bài 1:
Program HOC24;
var a: array[1..1000] of integer;
i,n,d: integer;
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
for i:=1 to n do if (a[i]<0) and (a[i] mod 2=0) then d:=d+1;
write('Co ',d,' so nguyen am chan trong day so');
readln
end.
Bài 2:
Program HOC24;
var a: array[1..1000] of integer;
i,n: integer;
t: longint;
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do if a[i] mod 5=0 then t:=t+a[i];
write(Tong la: ',t);
readln
end.
program TongSoChiaHetCho5;
var
n, i, x, tong: integer;
begin
write('Nhap so phan tu n: ');
readln(n);
tong := 0;
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(x);
if (x > 0) and (x mod 5 = 0) then
tong := tong + x;
end;
writeln('Tong cac so lon hon 0 va chia het cho 5 la: ', tong);
readln;
end.
Câu 1:
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
uses crt;
var i,n,n,d: integer;
t: longint;
A: array[1..32000] of integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
if a[i] >0 then
begin
d:=d+1;
t:=t+a[i];
end;
writeln('Tong la:',t);
write('Co tat ca so so duong la:',d);
readln;
end.
Giúp mình vs mình ko bt lm :((