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.
var n,i,k,d: integer;
a:array[1..52] of integer;
begin
write('Nhap so N: '); readln(n);
for i:=1 to n do
begin
write('a[',i,'] = '); readln(a[i]);
end;
write('Nhap so k: '); readln(k);
d:=0;
for i:=1 to n do
if a[i] mod k = 0 then d:=d+1;
writeln('Co ',d,' so chia het cho ',k,' trong day');
if d mod 2 = 0 then writeln('Chan') else writeln('Le');
end.
uses crt;
var a:array[1..52]of integer;
i,n,k,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=52);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
for i:=1 to n do
if a[i] mod k=0 then inc(dem);
writeln('Trong day co ',dem,' so chia het cho ',k);
if dem mod 2=0 then writeln('So luong so chia het cho ',k,' la so chan')
else writeln('So luong so chia het cho ',k,' la so le');
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,k,dem:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
readln(k);
dem:=0;
for i:=1 to n do
if a[i]>k then inc(dem);
write(dem);
readln;
end.
Bài 1:
Program HOC24;
var i,n,d : byte;
t: integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
for i:=1 to n do if (a[i] mod 3=0) and (a[i] mod 5=0) then
begin
d:=d+1;
t:=t+a[i];
end;
writeln('Co ',d,' phan tu la boi cua 3 va 5');
write('Tong la: ',t);
readln
end.
Bài 2:
Program HOC24;
var i,n,k : byte;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
write('Nhap k: '); readln(k);
for i:=1 to n do if a[i]=k then d:=d+1;
writeln('Co ',d,' phan tu bang ',k);
Write('Cac chi so do la: ');
for i:=1 to n do if a[i]=k then write(i,' ');
readln
end.
uses crt;
var a:array[1..100]of integer;
i,n,k,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod k=0 then t:=t+a[i];
writeln(t);
readln;
end.
Câu 1:
program mangsonguyen;
var
a: array[1..100] of integer;
i, n: integer;
begin
writeln('Nhap so phan tu trong mang: ');
readln(n);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
writeln('Mang vua nhap la:');
for i := 1 to n do
write(a[i], ' ');
end.
Câu 2:
program trungbinhcong;
var
a: array[1..100] of integer;
i, n, k, sum: integer;
avg: real;
begin
writeln('Nhap so phan tu trong mang: ');
readln(n);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
writeln('Nhap so k: ');
readln(k);
sum := 0;
for i := 1 to n do
begin
if a[i] <= k then
sum := sum + a[i];
end;
if sum > 0 then
begin
avg := sum / n;
writeln('Trung binh cong cac phan tu co gia tri <= ', k, ' la: ', avg:0:2);
end
else
begin
writeln('Khong co phan tu nao co gia tri <= ', k);
end;
end.
Câu 3:
program DemSoNguyenTo;
var
a: array [1..100] of integer;
i, j, n, count: integer;
laSoNguyenTo: boolean;
begin
write('Nhap so phan tu cua mang: ');
readln(n);
write('Nhap cac phan tu cua mang: ');
for i := 1 to n do
readln(a[i]);
count := 0;
writeln('Cac so nguyen to trong mang la: ');
for i := 1 to n do
begin
laSoNguyenTo := true;
for j := 2 to (a[i] div 2) do
begin
if (a[i] mod j = 0) then
begin
laSoNguyenTo := false;
break;
end;
end;
if laSoNguyenTo and (a[i] > 1) then
begin
writeln(a[i]);
count := count + 1;
end;
end;
writeln('Tong so cac so nguyen to la: ', count);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,k:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
writeln('Trong day co ',dem,' phan tu co gia tri bang ',k);
readln;
end.
uses crt;
var a:array[1..1000]of integer;
i,n,k,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
for i:=1 to n do
if a[i]=k then
begin
writeln(i);
break;
end;
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
if dem>0 then writeln('Co ',dem,' phan tu bang ',k)
else writeln('Khong co phan tu nao bang ',k);
readln;
end.
uses crt;
var n,k,i,dem:integer;
a:array[1..100]of integer;
begin
clrscr;
readln(n,k);
for i:=1 to n do
readln(a[i]);
dem:=0;
for i:=1 to n do
if a[i]>k then dem:=dem+1;
writeln(dem);
readln;
end.
program zoo;
var
i,n,k,d:integer;
a:array[1..32000] of integer;
function hello(x,y:integer):boolean;
begin
hello:=false;
if x mod y = 0 then hello := true
end;
begin
write(' nhap n: '); readln(n);
for i:= 1 to n do
begin
write(' nhap a[',i,'] = '); readln(a[i]);
end;
write(' nhap k = '); readln(k);
d:=0;
for i:= 1 to n do
if hello(a[i],k) = true then d:=d+1;
write(' so luong so chia het cho k la : ',d);
readln;
end.
const fi='k.inp';
fo='k.out';
var
i,n,k,d:integer;
a:Array[1..32000] of integer;
begin
assign(f,fi);
reset(f);
readln(f,n);
for i:= 1 to n do
read(f,a[i]);
readln(f);
read(f,k);
close(f);
assign(f,fO);
rewrite(f);
d:=0;
for i:= 1 to n do
if a[i] mod k = 0 then inc(d);
write(f,' co ',d,'so chia het cho',k);
close(f);
end.