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 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.
Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long a[250],i,n,k;
int main()
{
cin>>n>>k;
for (i=1; i<=n; i++)
cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]==k) cout<<i<<" ";
return 0;
}
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.
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.
phần đọc tự viết
for i:=j to n do
b[i+1]:=a[i];
for i:=1 to j do write(g,a[i]);
write(g,M);
for i:=j+1 to n+1 do
write(g,b[i]);
uses crt;
var a,b:array[1..100]of integer;
i,n,m,k,tam: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]:6);
writeln;
write('Nhap m='); readln(m);
write('Nhap chi so k='); readln(k);
for i:=1 to k do
b[i]:=a[i];
for i:=k+2 to n+1 do
b[i]:=a[i-1];
b[k+1]:=m;
for i:=1 to n+1 do
write(b[i]:6);
readln;
end.