主题:关于线性表的操作
Program list;
var
a : array[1..20] of integer;
i,l : integer;
procedure print;
var
i : integer;
begin
for i:=1 to l do write(a[i]:3);
writeln;
end;
Procedure del(i:integer);(能不能解释一下??)
var j:integer;
begin
if l>0 then begin
for j:=i+1 to l do a[j-1]:=a[j];
dec(l);
end;
end;
Procedure insert(i,m:integer);(能不能解释一下??)
var j:integer;
begin
inc(l);
for j:=l downto i+1 do
a[j]:=a[j-1];
a[j]:=m;
end;
Function find(v:integer):integer;
var
i:integer;
begin
i:=1;
while (a[i]<>v) and (i<=l) do inc(i);
find:=i;
end;
begin
l:=10;
for i:=1 to l do a[11-i]:=i;
print;
del(3);
print;
insert(3,15);
print;
writeln(find(15));
readln;
end.
var
a : array[1..20] of integer;
i,l : integer;
procedure print;
var
i : integer;
begin
for i:=1 to l do write(a[i]:3);
writeln;
end;
Procedure del(i:integer);(能不能解释一下??)
var j:integer;
begin
if l>0 then begin
for j:=i+1 to l do a[j-1]:=a[j];
dec(l);
end;
end;
Procedure insert(i,m:integer);(能不能解释一下??)
var j:integer;
begin
inc(l);
for j:=l downto i+1 do
a[j]:=a[j-1];
a[j]:=m;
end;
Function find(v:integer):integer;
var
i:integer;
begin
i:=1;
while (a[i]<>v) and (i<=l) do inc(i);
find:=i;
end;
begin
l:=10;
for i:=1 to l do a[11-i]:=i;
print;
del(3);
print;
insert(3,15);
print;
writeln(find(15));
readln;
end.