BzDoN, че-то создал... не знаю, то - не то..
Code
Program ListToArray;
Uses CRT;
Const MAXARRAY = 32;
Type toList = ^List;
List = record
info: Byte;
link: toList;
end;
Var
a: Array[1..MAXARRAY] of Integer;
size: Byte;
temp: Integer;
i: Byte;
first, next, curr: toList;
Function EnterElements: Integer;
Var _size: Byte;
Begin
ClrScr;
_size := 0;
Repeat
Write('Введите очередной элемент (-отрицательный, если закончили): '); Readln(temp);
if (temp < 0) then Break
else begin
Inc(_size);
a[_size] := temp;
end;
Until (false) or (_size = MAXARRAY);
EnterElements := _size;
End;
Function List2Array: Boolean;
Var i: Byte;
Begin
i := 0;
next := first;
While (next <> nil) do
Begin
Inc(i);
a[i] := next^.info;
next:=next^.link;
End;
List2Array := True;
End;
Function Array2List: Boolean;
Var i: Byte;
Begin
For i := 1 to size do
Begin
next := New(toList);
next^.info := a[i];
next^.link := nil;
if (first = nil) then
begin
first := next;
curr := first;
end
else
begin
curr^.link := next;
curr := next;
end;
End;
Array2List := True;
End;
Procedure PrintList;
Begin
next := first;
While (next <> nil) do
Begin
Write(next^.info:5);
next:=next^.link;
End;
ReadKey;
End;
Procedure PrintArray;
Begin
For i := 1 to size do
Begin
Write(a[i]:5);
End;
Readkey;
End;
Procedure destroy;
Var die: toList;
Begin
next := first;
Writeln(first^.info);
While (next <> nil) do
Begin
die := next;
next:=next^.link;
Writeln(#13#10,'умер элемент: ',die^.info,' соболезнования близким');
Dispose(die);
End;
End;
Begin
size := EnterElements;
Writeln('Из массива в список:');
if (Array2List) then PrintList;
Writeln(#13#10,'Из списка в массив:');
if (List2Array) then PrintArray;
Writeln(#13#10,'Убиваем элементы');
destroy;
ReadKey;
End.