Ai giúp mk xem bài này có lỗi nào sai không ạ? Mk thử cho chạy trên pascal trên điện thoại mà ko đc ạ Program ontapbai11_mang1chieu; uses crt; type M1

By Josephine

Ai giúp mk xem bài này có lỗi nào sai không ạ? Mk thử cho chạy trên pascal trên điện thoại mà ko đc ạ
Program ontapbai11_mang1chieu;
uses crt;
type M1d=array[1..100] of longint;
var A:M1d;
n,i,j,k :byte;
max,s:longint;
demle,demnto:byte;
nto:boolean;
tam:longint;
Begin
clrscr;
{ Nhap mang 1 chieu }
Write( ‘ Nhap so luong phan tu n= ‘);
read(n);
For i:=1 to n do
begin
Write(‘A[‘,i,’]=’);
read(A[i]);
end;
Writeln;

Writeln(‘Mang vua nhap co ‘, n , ‘ phan tu nhu sau:’);
for i:=1 to n do Write(a[i]: 10);
Writeln;

s:=0;
for i:=1 to n do
s:=s+A[i];

Writeln(‘Tong cac phan tu cua mang la = ‘, s);

Writeln(‘Cac phan tu le cua mang la:’);
for i:=1 to n do
if A[i] mod 2 = 1 then
Write(a[i]:10);

writeln;
demle:=0;
for i:=1 to n do
if A[i] mod 2 = 1 then
demle:=demle+1;
Writeln(‘Mang tren co ‘ , demle ,’ phan tu le’);
{xuat ra cac phan tu chi het cho k}
Writeln(‘ Nhap so k= ‘);
read(k);
Writeln(‘ Cac Phan tu chia het cho k=’,k,’ la:’);
for i:=1 to n do
if A[i] mod k =0 then
Write(A[i]:10);

writeln;
max:=A[1];
for i:=1 to n do
if A[i]> max then Max:=A[i];
Writeln (‘ Phan tu lon nhat cua mang la: ‘, max);

j:=1;
for i:=1 to n do
if A[i]> A[j] then j:=i;
Writeln(‘ Phan tu lon nhat la= ‘, A[j] , ‘ vi thu ‘ ,j);

writeln;
Writeln(‘Cac so nguyen to cua mang la:’);
for i:=1 to n do
begin
nto:=true;
for j:=2 to A[i] do
if A[i] mod j = 0 then
nto:=false;
if nto= true then Write(A[i]:10);
end;

writeln;
demnto:=0;
for i:=1 to n do
begin
nto:=true;
for j:=2 to A[i] do
if A[i] mod j = 0 then
nto:=false;
if nto = true then demnto:=demnto+1;
end;
Writeln(‘Mang tren co ‘, demnto , ‘ so nguyen to’);

for j:=n downto 2 do
for i:=1 to j-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 sau khi da sap xep nhu sau:’);
For i:=1 to n do Write(A[i]:10);
end.




Viết một bình luận