Advertisement
ksyshshot

Lib_5)1

Mar 31st, 2023
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.67 KB | Source Code | 0 0
  1. {procedure AddElementInList(var Prev: TPointer; Data: Integer);
  2. var
  3.     Temp: TPointer;
  4. begin
  5.     New(Temp);
  6.     Temp^.Data := Data;
  7.     Temp^.Next := nil;
  8.     Prev^.Next := Temp;
  9. end;}
  10.  
  11. {function CopyList(Start: TPointer): TPointer;
  12. var
  13.     NewStart, Curr, NewElement: TPointer;
  14. begin
  15.     New(Curr);
  16.     New(NewElement);
  17.     New(NewStart);
  18.     Curr := Start^.Next^.Next;
  19.     NewStart^.Next := NewElement;
  20.     NewElement^.Data := Start^.Next^.Data;
  21.     while (Curr <> nil) do
  22.     begin
  23.         AddElementInList(NewElement, Curr^.Data);
  24.         NewElement := NewElement^.Next;
  25.         Curr := Curr^.Next;
  26.     end;
  27.     CopyList := NewStart;
  28. end;}
  29.  
  30. {function ReplaceElements(var PrevElem: TPointer; NextElem: TPointer; Data: Integer): TPointer;
  31. var
  32.     Temp: TPointer;
  33. begin
  34.     New(Temp);
  35.     Temp^.Data := Data;
  36.     PrevElem^.Next := Temp;
  37.     Temp^.Next := NextElem;
  38.     ReplaceElements := Temp;
  39. end;}
  40.  
  41. {function ChangeList(Start: TPointer): TPointer;
  42. var
  43.     Temp, Current, NewStart, NewElement: TPointer;
  44.     NewData: Integer;
  45. begin
  46.     New(NewStart);
  47.     NewStart := CopyList(Start);
  48.     New(NewElement);
  49.     Current := Start^.Next;
  50.     NewElement := NewStart^.Next;
  51.     while (Current <> nil) do
  52.     begin
  53.         Temp := Start^.Next;
  54.         NewData := Start^.Next^.Data;
  55.         while (Temp <> Current) do
  56.         begin
  57.             NewElement := ReplaceElements(NewElement, NewElement^.Next, NewData);
  58.             Temp := Temp^.Next;
  59.             if (Temp <> Current) then
  60.                 NewData := Temp^.Data;
  61.         end;
  62.         Current := Current^.Next;
  63.         NewElement := NewElement^.Next;
  64.     end;
  65.     ChangeList := NewStart;
  66. end;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement