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;
i,t,t1:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to 10 do
if a[i] mod 2<>0 then
begin
write(a[i]:4);
t:=t+a[i];
end;
writeln;
writeln('Tong cac so le la: ',t);
t1:=0;
for i:=1 to 10 do
t1:=t1+a[i];
writeln('Tong cac phan tu cua mang la: ',t1);
readln;
end.
program bt;
uses crt;
var i, s, sa, sd, sc, sl, da, dd, dc, dl : integer;
a : array[1..50] of integer;
begin
clrscr;
for i:=1 to 10 do begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
write('Day so vua nhap la: ');
for i:=1 to 10 do write(a[i],', ');
writeln;
s := 0; sa := 0; sd := 0; sc := 0; sl := 0; da := 0; dd := 0; dc := 0; dl := 0;
for i:=1 to 10 do begin
s := s + a[i];
if (a[i] > 0) then begin sd := sd + a[i]; dd := dd + 1 end;
if (a[i] < 0) then begin sa := sa + a[i]; da := da + 1 end;
if (a[i] mod 2 = 0) then begin sc := sc + a[i]; dc := dc + 1; end
else begin sl := sl + a[i]; dl := dl + 1 end;
end;
writeln('Tong cac phan tu trong mang la ',s);
writeln('Trung binh cong cac phan tu trong mang la ',s/10);
writeln('Tong cac so am la ',sa);
writeln('Tong cac so duong la ',sd);
writeln('Tong cac so chan la ',sc);
writeln('Tong cac so le la ',sl);
writeln('So cac so am la ', da);
writeln('So cac so duong la ', dd);
writeln('So cac so chan la ', dc);
writeln('So cac so le la ', dl);
readln
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,max,t,min,dem1:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
max:=-32000;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
dem:=dem+1;
if max<a[i] then max:=a[i];
end;
if dem=0 then writeln('Trong day khong co so chan')
else begin
writeln('So so chan la: ',dem);
writeln('So chan lon nhat la: ',max);
end;
t:=0;
for i:=1 to n do
if i mod 2=1 then t:=t+a[i];
writeln('Tong cac so o vi tri le la: ',t);
min:=maxint;
dem1:=0;
for i:=1 to n do
if a[i] mod 2<>0 then
begin
inc(dem1);
if min>a[i] then min:=a[i];
end;
if dem1=0 then writeln('Trong day khong co so le')
else writeln('So le nho nhat la: ',min);
readln;
end.
program TinhTongMang;
var
a: array[1..10] of integer;
i, tong: integer;
begin
tong := 0;
writeln('Nhap mang a gom 10 phan tu:');
for i := 1 to 10 do
begin
write('a[', i, '] = ');
readln(a[i]);
tong := tong + a[i];
end;
writeln('Tong cac phan tu cua mang la: ', tong);
end.
program b1;
uses crt;
var i: integer; a:array[1..100] of integer; s:longint;
begin
clrscr;
for i:=1 to 10 do
begin
write('a[',i,']='); readln(a[i]);
end;
writeln('cac phan tu chan la:');
s:=0;
for i:=1 to 10 do if a[i] mod 2=0 then writeln(a[i],' ');
write('Tong cac phan tu le la:');
for i:=1 to 10 do if a[i] mod 2<>0 then s:=s+a[i]; write(s);
readln;
end.
Tham khảo!
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.
var a:array[1..100] of real;
i,b:integer;
s:real;
begin
write('Nhap so luong phan tu ');readln(b);
for i:=1 to b do
begin
write('Nhap phan tu thu ',i,' = ');readln(a[i]);
s:=s+a[i];
end;
write('Tong cac phan tu la ',s:10:2);
readln
end.
a)Var z:array[1..1000] of longint;
n, i,S:longint;
Begin
S:=0;
Readln(n);
For i:=1 to n do begin writeln('s',i,'=');
Readln(z[i]);
End;
For i:=1 to n do if z[i] mod 2 = 0 then begin S:=S + z[i];
End;
Writeln('Tong chan la ',S);
End.
b)
Var z:array[1..1000] of longint;
n, i, chan, le:longint;
Begin
S:=0;
Readln(n);
For i:=1 to n do begin writeln('s',i,'=');
Readln(z[i]);
End;
For i:=1 to n do if z[i] mod 2 = 0 then begin write(z[i]:10);
Writeln('chan');
chan:=z[i];
End;
For i:=1 to n do if z[i] mod 2 = 0 then begin write(z[i]:10);
Writeln('chan');
chan:=z[i];
End;
If chan>le then writeln('So phan tu chan trong mang nhieu hon')
else writeln('So phan tu le trong mang nhieu hon');
End.
Cậu thử kiểm tra lại nhé!