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,t1,t2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
writeln;
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
writeln;
t1:=0;
t2:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then t1:=t1+a[i]
else t2:=t2+a[i];
end;
writeln(t1);
writeln(t2);
readln;
end.
Bài 5:
Var a:array:[1..1000] of integer;
i,n,max:integer;
sc, sl:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');rreadlna[i]);
If a[i] mod 2 = 0 then sc:=sc+b[i];
If a[i] mod 2 <> 0 then sl:=sl+a[i];
End;
max:=a[1];
For i:=2 to n do
If a[i] > max then max:=a[i];
Writeln('Tong cac so chan la ',sc);
Writeln('Tong cac so le la ',sl);
write('So lon nhat la ',max);
Readln
End.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
Program HOC24;
var d,i,n: integer;
t: real;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
d:=0; t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
d:=d+1;
t:=t+a[i];
end;
t:=t/d;
writeln('Co ',d,' so chan trong mang');
writeln('Trung binh cong cac phan tu chan la: ',t:2:5);
write('Cac phan tu trong day theo chieu doc: ');
for i:=1 to n do writeln(a[i]);
readln
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+a[i];
end;
max:=a[1];
min:=a[1];
for i:=1 to n do begin
if(max<a[i]) then max:=a[i];
if(min>a[i]) then min:=a[i];
end;
Writeln('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+a[i];
end;
max:=a[1];
min:=a[1];
for i:=1 to n do begin
if(max<a[i]) then max:=a[i];
if(min>a[i]) then min:=a[i];
end;
Writeln('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.
Bài 1:
program in_phan_tu;
uses crt;
var n,i:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:3);
readln;
end.
Bài 2:
program tong_phan_tu;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Bài 3:
program tong_phan_tu_chan;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
if a[i] mod 2=0 then tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.