//Pascal ABC.NET 3.1 сборка 1256
Type
ukreco=^reco;
reco=record
int:integer;
next:ukreco;
end;
Const
n=4;
Var
head,li,kar,karsub,sub:ukreco;
i,k:integer;
begin
randomize;
readln(k);
k:=k-1;
new(head);
li:=head;
li^.int:=random(10);
for i:=2 to n do
begin
new(li^.next);
li:=li^.next;
li^.int:=random(10);
end;
li^.next:=nil;
writeln('Original list:');
kar:=head;
while kar<>nil do
begin
writeln(kar^.int);
kar:=kar^.next;
end;
kar:=head;
i:=0;
if k=0 then head:=head^.next else
while kar<>nil do
begin
inc(i);
if i=k then
begin
karsub:=kar^.next;
karsub:=karsub^.next;
kar^.next:=karsub;
break;
end;
kar:=kar^.next;
end;
writeln('Modified list:');
kar:=head;
while kar<>nil do
begin
writeln(kar^.int);
kar:=kar^.next;
end;
end.
Пример ввода:
2
Пример вывода:
Original list:
4
1
0
9
Modified list:
4
0
9