Zrobiłem coś takiego:
program test1;
uses crt;
type
t_lista_dwukierunkowa = ^lista_dwukierunkowa;
{-----------------------------------------------------}
lista_dwukierunkowa = record
nastepna : t_lista_dwukierunkowa;
poprzednia : t_lista_dwukierunkowa;
dana : integer;
end;
{-----------------------------------------------------}
var
lista : t_lista_dwukierunkowa;
temp : t_lista_dwukierunkowa;
liczba : integer;
{-----------------------------------------------------}
procedure do_listy;
begin
write('> Podaj liczbe: '); readln(liczba);
if lista = nil then
begin
new(lista);
lista^.nastepna := nil;
lista^.poprzednia := nil;
lista^.dana := liczba;
end
else
begin
new(temp);
temp^.nastepna := nil;
temp^.poprzednia := lista;
lista^.nastepna := temp;
temp^.dana := liczba;
lista := temp;
end;
end;
{-----------------------------------------------------}
procedure usun;
var pomoc : t_lista_dwukierunkowa;
usuwana : integer;
begin
write('> Podaj liczbe do usuniecia : '); readln(usuwana);
lista := temp^.nastepna;
pomoc := lista;
temp := lista;
while temp <> nil do
begin
if usuwana = temp^.dana then
begin
pomoc^.nastepna := temp^.nastepna;
dispose(temp);
temp := pomoc;
end;
pomoc := temp;
temp := temp^.nastepna;
end;
readln;
end;
{-----------------------------------------------------}
procedure menu;
var znak : char;
begin
repeat;
clrscr;
writeln('1. dodaj do listy');
writeln('2. usun pojedyncza liczbe');
writeln('3. koniec');
znak := readkey;
case znak of
'1': do_listy;
'2': usun;
end;
until znak = '3';
end;
{-----------------------------------------------------}
BEGIN
clrscr;
menu;
readln;
END.
Bez problemu dodają się do listy, ale gorzej z usunieciem pojedynczej liczby coś robię źle tylko co ?
Wprowadzi ktoś poprawkę ?