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,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.
#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;
}
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.
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.
program bai_2;
uses crt;
var a:array[1..100]of byte;
n,i,j,tam,vt,vt2,x,x2,k,ch:byte;
procedure yc1;
begin
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);
end;
procedure yc2;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
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:');for i:=1 to n do write(a[i]:3);
end;
procedure yc3;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
write('nhap so x:');readln(x);
for i:=n downto 1 do
if a[i]=x then vt:=i;if a[i]=x then writeln('vi tri cua ',x,' trong mang a la:',vt);writeln;
if a[i]<>x then writeln('khong tim thay ',x,' trong day so tren');writeln;
end;
procedure yc4;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
write('nhap so x2:');readln(x2);
for i:=n downto 1 do
if a[i]=x2 then vt2:=i;if x>0 then
begin
for i:=vt2 to n-1 do a[i]:=a[i+1];
for i:=1 to n-1 do write(a[i]:3);
end
else if a[i]<>x2 then write('khong tim thay ',x2,' trong day so tren');
end;
procedure yc5;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
write('nhap vi tri:');readln(vt);
for i:=1 to n do
if (vt=i) then writeln('phan tu o vi tri ',vt,' la:',a[vt]:3);
for i:=vt to n-1 do a[i]:=a[i+1];
for i:=n downto vt+1 do a[i]:=a[i-1];
write('nhap so can sua:');readln(a[vt]);
writeln('day so sau khi sua la:');
for i:=1 to n do write(a[i]:3); writeln;
end;
procedure yc6;
begin
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
write('nhap vi tri can chen k:');readln(k);
for i:=n+1 downto k+1 do a[i]:=a[i-1];
write('nhap so can chen vao day:');readln(a[k]);
writeln('day so sau khi chen ',a[k],' vao day la:');
for i:=1 to n+1 do write(a[i]:3);writeln;
end;
procedure yc7;
begin
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);
writeln;
end;
BEGIN
clrscr;
while ch<8 do
begin
clrscr;
writeln('CHON MOT TRONG CAC SO SAU:');
writeln('1.NHAP DAY SO:');
writeln('2.SAP XEP DAY SO:');
writeln('3.TIM MOT SO:');
writeln('4.XOA MOT SO:');
writeln('5.SUA MOT SO:');
writeln('6.CHEN MOT SO:');
writeln('7.IN DAY SO:');
writeln('8.THOAT KHOI CHUONG TRINH:');
write('nhap so co yeu cau ban muon lam:');readln(ch);
if ch<8 then
begin write('nhap so n:');readln(n); end;
case ch of
1:yc1;
2:yc2;
3:yc3;
4:yc4;
5:yc5;
6:yc6;
7:yc7;
end;
readln;
end;
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.