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.
Program HOC24;
var i,d,n: integer;
a: array[1..32000] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('Nhap k: '); readln(k);
d:=0;
for i:=1 to n do if a[i]=k then d:=d+1;
write('Co ',d,' phan tu bang ',k);
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.
Var i,k,n,bk,tong: integer;
a: array[1..1000] of integer;
Begin
write('Nhap K: '); readln(k);
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
{câu a}
For i:=1 to n do
if a[i]=k then bk:=bk+1;
writeln('Co so phan tu bang k la:',k);
{câu b}
For i:=1 to n do
if a[i]=k then
begin
write(i,' ');
tong:=tong+a[i];
end;
write('. Tong la:',tong);
readln
end.
uses crt;
var k,n,tong,d,i:longint;a:array[1..1000]of longint;
begin
clrscr;
write('n=');readln(n);
write('k=');readln(k);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
d:=0;
for i:=1 to n do if(a[i]=k)then inc(d);
writeln('so phan tu bang voi:',k,' la:',d);
write('cac so co vi tri bang voi:',k,' la:');
tong:=0;
for i:=1 to n do if(a[i]=k)then
begin
write(i,' ');
tong:=tong+a[i];
end;
write('tong cua cac so bang voi:',k,' la:',tong);
readln;
end.
var a:array[1..100] of integer;
i,n,S,d:byte;
begin
write(' n = '); readln(n);
for i:=1 to n do begin
write('A[',i,'] = ');
readln(A[i]);
end;
d:=0; S:=0;
for i:=1 to n do if A[i] mod 2 = 0 then begin
d:=d+1;
S:=S+A[i];
end;
write('Dãy có ',d,' phần tử là số chẵn và tổng của chúng là : S = ',S);
readln
end.
uses crt;
var a:array[1..200]of integer;
n,i,k,t,t1: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 2<>0 then t:=t+a[i];
t1:=0;
for i:=1 to n do
if a[i] mod k=0 then t1:=t1+a[i];
writeln('Tong cac phan tu le la: ',t);
writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);
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 a:array[1..250]of integer;
i,n,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('Gia tri lon nhat la: ',max);
writeln('Vi tri cua no trong mang la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
readln;
end.
Câu 1:
var a:array[1..100]of integer;
Câu 2:
uses crt;
var a:array[1..10]of integer;
i:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to 10 do
write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..15]of integer;
i,n,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=15);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]<=100;
end;
writeln('Mang da nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('Tong cac phan tu chia het cho 3 la: ',t);
writeln('Cac so chan o vi tri le trong day la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (i mod 2=1) then write(a[i]:4);
readln;
end.
uses crt;
var C : array [1 .. 50] of integer;
i, n : integer;
begin
clrscr;
write('Nhap so phan tu : '); readln(n);
write('Nhap day gom ', n ,' so : ');
for i := 1 to n do read(C[i]);
write('Cac gia tri chan : ');
for i := 1 to n do
if C[i] mod 2 = 0 then write(C[i], ' ');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,k,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
cin>>k;
dem=0;
for (i=1; i<=n; i++)
if (a[i]==k) dem++;
cout<<dem;
return 0;
}