program baicuaban;
Var a:array [1..100] Of integer;
k,n,i,tam,x:integer;
Begin
Write('Nhap so phan tu n:');
ReadLn(n);
For i:=1 to n do
Begin
Write('a[',i,']=');
ReadLn(a[i]);
End;
For k:=1 to (n-1) do
For i:=1 to (n-1) do
If a[i] > a[i+1] then
Begin
tam:=a[i];
a[i]:=a[i+1];
a[i+1]:=tam;
End;
WriteLn('Mang da sap xep:');
For i:=1 to n do write(a[i],' ');
WriteLn;
Write('nhap vao so X :');
ReadLn(X);
i:=1;
While (x>a[i]) and(i<=n) do i:=i+1;
For k:=n+1 downto i do
a[k]:=a[k-1];
a[i]:=x;
Write('Mang da chen X:');
For i:=1 to n+1 do write(a[i],' ');
ReadLn;
End.
CHÚC BẠN HỌC TỐT.sai hãy liên hệ với mình, đúng tick cho mình nha
program baicuaban;
Var a:array [1..100] Of integer;
k,n,i,tam,x:integer;
Begin
Write('Nhap so phan tu n:');
ReadLn(n);
For i:=1 to n do
Begin
Write('a[',i,']=');
ReadLn(a[i]);
End;
For k:=1 to (n-1) do
For i:=1 to (n-1) do
If a[i] > a[i+1] then
Begin
tam:=a[i];
a[i]:=a[i+1];
a[i+1]:=tam;
End;
WriteLn('Mang da sap xep:');
For i:=1 to n do write(a[i],' ');
WriteLn;
Write('nhap vao so X :');
ReadLn(X);
i:=1;
While (x>a[i]) and(i<=n) do i:=i+1;
For k:=n+1 downto i do
a[k]:=a[k-1];
a[i]:=x;
Write('Mang da chen X:');
For i:=1 to n+1 do write(a[i],' ');
ReadLn;
End.
Mik cần gấp vào sáng mai, giúp mik vs hu hu