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..300]of integer;
i,n,dem,kt,t: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 3=0 then inc(dem);
t:=abs(a[2]-a[1]);
kt:=0;
for i:=1 to n do
if t<>abs(a[i]-a[i-1]) then
begin
kt:=1;
break;
end;
if kt=0 then writeln('Day la cap so cong')
else writeln('Day khong la cap so cong');
readln;
end.
uses crt;
var a:array[1..100]of longint;
i,n,t,t1,tam,j:integer;
s,s1:int64;
begin
clrscr;
repeat
write('nhap n='); readln(n);
until n>0;
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
until a[i]>=0;
end;
writeln('Mang A=');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong gia tri cua mang A la: ',t);
s:=1;
for i:=1 to n do
s:=s*i;
writeln('Tich cac gia tri cua mang A la: ',s);
t1:=0;
for i:=1 to n do
if i mod 2=0 then t1:=t1+a[i];
writeln('Tong cac gia tri o vi tri chan la: ',t1);
s1:=1;
for i:=1 to n do
if i mod 2<>0 then s1:=s1*a[i];
writeln('Tich cac gia tri o vi tri le la: ',s1);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('Mang A sau khi sap xep la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
writeln('Cac phan tu co gia tri lon hon 10 la: ');
for i:=1 to n do
if a[i]>10 then write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,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 3=0 then inc(dem);
writeln(dem);
readln;
end.
uses crt;
var a:array[1..1000]of integer;
i,n,dem,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=1000);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until abs(a[i])<=1000;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]=0 then inc(dem);
writeln('So phan tu bang 0 la: ',dem);
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu chan la: ',t);
readln;
end.
program boi_cua_3;
uses crt;
var a:array[1..100] of integer;
n,i:byte;
s:integer;
begin
clrscr;
write('nhap so luong phan tu cua mang: ');
readln(n);
for i:= 1 to n do
begin
write('nhap phan tu thu [',i,']= ');
readln(a[i]);
end;
s:=0;
for i:= 1 to n do
if a[i] mod 3 = 0 then s:=s+a[i];
writeln('vay tong cac so la boi cua 3 la: ',s);
readln;
end.
uses crt;
var a:array[1..100]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;
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong mang do la: ',t);
readln;
end.
uses crt;
var a:array[1..50]of integer;
n,i,dem,tbc:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chan la: ');
dem:=0;
tbc:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i]:4);
inc(dem);
tbc:=tbc+a[i];
end;
writeln;
writeln('So phan tu chan la: ',dem);
writeln('Trung binh cong cua cac so chan trong day la: ',tbc/dem:4:2);
readln;
end.
Program HOC24;
var i,n: integer;
a: array[1..32000] of integer;
t: longint;
begin
write('Nhap N: '); readln(n);
t:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if a[i] mod 3=0 then t:=t+a[i];
end;
write('Tong cac phan tu chia het cho 3 la: ',t);
readln
end.
uses crt;
var a:array[1..100]of integer;
n,i,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 3=0 then t:=t+a[i];
writeln(t);
readln;
end.